Trigger inline adding with a custom event

This commit is contained in:
Andrew Short 2013-06-25 20:16:54 +10:00
parent 159b9bbd5c
commit dc16c34d6e

View File

@ -89,22 +89,23 @@
if(success) success.apply(grid, arguments); if(success) success.apply(grid, arguments);
}); });
} },
}) onaddnewinline: function() {
$(".ss-gridfield-add-new-inline").entwine({
onclick: function() {
var tmpl = window.tmpl; var tmpl = window.tmpl;
var grid = this.getGridField(); var row = this.find(".ss-gridfield-add-inline-template");
var row = grid.find(".ss-gridfield-add-inline-template"); var num = this.data("add-inline-num") || 1;
var num = grid.data("add-inline-num") || 1;
tmpl.cache["ss-gridfield-add-inline-template"] = tmpl(row.html()); tmpl.cache["ss-gridfield-add-inline-template"] = tmpl(row.html());
grid.find("tbody").append(tmpl("ss-gridfield-add-inline-template", { num: num })); this.find("tbody").append(tmpl("ss-gridfield-add-inline-template", { num: num }));
grid.find(".ss-gridfield-no-items").hide(); this.find(".ss-gridfield-no-items").hide();
grid.data("add-inline-num", num + 1); this.data("add-inline-num", num + 1);
}
});
$(".ss-gridfield-add-new-inline").entwine({
onclick: function() {
this.getGridField().trigger("addnewinline");
return false; return false;
} }
}); });