-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRockGridAjax.js
42 lines (38 loc) · 877 Bytes
/
RockGridAjax.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* RockGrid AJAX class
* todo: make plugin instead of single js file
*/
function RockGridAJAX(grid, params) {
this.grid = grid;
this.params = params;
this.doneCallback = function(params) {};
/**
* get url for ajax request
*/
this.getUrl = function() {
var url = location.href.split('#')[0]; // make sure url has no hashtag
if(url.indexOf('?') === -1) url += '?RockGrid=1';
else url += '&RockGrid=1';
url += '&field=' + this.grid.id;
return url;
}
this.getParams = function() {
if(this.params.length) return this.params.join();
else return this.params;
}
// execute this request
var AJAX = this;
$.post(
this.getUrl(),
params,
function(params) {
AJAX.doneCallback(params);
}
);
};
/**
* callback when done
*/
RockGridAJAX.prototype.done = function(func) {
this.doneCallback = func;
}