diff options
author | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2014-02-22 23:27:03 +0200 |
---|---|---|
committer | Kaarle Ritvanen <kaarle.ritvanen@datakunkku.fi> | 2014-02-24 13:05:52 +0200 |
commit | 22b17333e30c60e163b88af9ed88b325223d23ea (patch) | |
tree | 51bb888211d0f74b697fb308a4cf9c3350afcf67 | |
parent | c81290f4f2a119cf38dee8a3d5111d0d67c54c1e (diff) | |
download | aconf-22b17333e30c60e163b88af9ed88b325223d23ea.tar.bz2 aconf-22b17333e30c60e163b88af9ed88b325223d23ea.tar.xz |
web client: button creation routine
-rw-r--r-- | web/dom.js | 6 | ||||
-rw-r--r-- | web/widget/inline.js | 18 |
2 files changed, 14 insertions, 10 deletions
@@ -23,6 +23,12 @@ define(["acf2/navigation", "jquery", "underscore"], function(navi, $, _) { return el; }, + button: function(label, func) { + return $("<input>").attr( + {type: "submit", value: label} + ).click(func); + }, + makeRow: function(el) { if (el.is("td")) return $("<tr>").html(el); return el; diff --git a/web/widget/inline.js b/web/widget/inline.js index 8a81854..e9fe068 100644 --- a/web/widget/inline.js +++ b/web/widget/inline.js @@ -25,13 +25,13 @@ define( if (meta.type == "model") _.each(meta.actions, function(action) { - self.div.append($("<input>").attr( - {type: "submit", value: action["ui-name"]} - ).click(function() { - data.invoke(action.name) - .done(function() { alert("Done"); }) - .fail(function() { alert("Failed"); }); - })); + self.div.append( + dom.button(action["ui-name"], function() { + data.invoke(action.name) + .done(function() { alert("Done"); }) + .fail(function() { alert("Failed"); }); + }) + ); }); }, @@ -43,9 +43,7 @@ define( var self = this; var keys = _.clone(_.keys(data.data)); - var button = $("<input>").attr( - {type: "submit", value: "Insert"} - ).click(function() { + var button = dom.button("Insert", function() { var getter, row; |