我正在使用此示例将数据导入 Fuel UX 数据网格:http ://dailyjs.com/2012/10/29/fuel-ux/ (显然使用我自己的 API 而不是 Flickr)
我在示例代码中看到数据在搜索时刷新:
data: function (options, callback) {
var url = 'http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=d6d798f51bbd5ec0a1f9e9f1e62c43ab&format=json';
var self = this;
if (options.search) {
// Search active. Add URL parameters for Flickr API.
url += '&tags=' + options.search;
url += '&per_page=' + options.pageSize;
url += '&page=' + (options.pageIndex + 1);
$.ajax(url, {
// Set JSONP options for Flickr API
dataType: 'jsonp',
jsonpCallback: 'jsonFlickrApi',
jsonp: false,
type: 'GET'
}).done(function (response) {
// Prepare data to return to Datagrid
var data = response.photos.photo;
var count = response.photos.total;
var startIndex = (response.photos.page - 1) * response.photos.perpage;
var endIndex = startIndex + response.photos.perpage;
var end = (endIndex > count) ? count : endIndex;
var pages = response.photos.pages;
var page = response.photos.page;
var start = startIndex + 1;
// Allow client code to format the data
if (self._formatter) self._formatter(data);
// Return data to Datagrid
callback({ data: data, start: start, end: end, count: count, pages: pages, page: page });
});
} else {
// No search. Return zero results to Datagrid
callback({ data: [], start: 0, end: 0, count: 0, pages: 0, page: 0 });
}
但是,我想使用各种刷新按钮来重新加载数据。我将如何传递这样的请求?