summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2014-02-22 23:27:03 +0200
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2014-02-24 13:05:52 +0200
commit22b17333e30c60e163b88af9ed88b325223d23ea (patch)
tree51bb888211d0f74b697fb308a4cf9c3350afcf67
parentc81290f4f2a119cf38dee8a3d5111d0d67c54c1e (diff)
downloadaconf-22b17333e30c60e163b88af9ed88b325223d23ea.tar.bz2
aconf-22b17333e30c60e163b88af9ed88b325223d23ea.tar.xz
web client: button creation routine
-rw-r--r--web/dom.js6
-rw-r--r--web/widget/inline.js18
2 files changed, 14 insertions, 10 deletions
diff --git a/web/dom.js b/web/dom.js
index 8e0e257..5c8fb8e 100644
--- a/web/dom.js
+++ b/web/dom.js
@@ -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;