[#168,docs/backend][m]: major extension to backend tutorial to give examples of most backends.
This commit is contained in:
22
_includes/example-backends-csv-disk.js
Normal file
22
_includes/example-backends-csv-disk.js
Normal file
@@ -0,0 +1,22 @@
|
||||
// the file input
|
||||
var $file = $('.my-file-input')[0];
|
||||
|
||||
// listen for the file to be submitted
|
||||
$($file).change(function(e) {
|
||||
// create the dataset in the usual way but specifying file attribute
|
||||
var dataset = new recline.Model.Dataset({
|
||||
file: $file.files[0],
|
||||
backend: 'csv'
|
||||
});
|
||||
|
||||
// now load - note that this is again async (HTML5 File API is async)
|
||||
// dataset.fetch().done(function() { console.log('here'); });
|
||||
dataset.fetch();
|
||||
|
||||
// For demonstrations purposes display the data in a grid
|
||||
var grid = new recline.View.Grid({
|
||||
model: dataset
|
||||
});
|
||||
$('#my-csv-disk').append(grid.el);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user