summaryrefslogtreecommitdiff
path: root/public
diff options
context:
space:
mode:
authormr <mr@mrautenberg.de>2011-01-31 11:45:53 +0100
committermr <mr@mrautenberg.de>2011-01-31 11:45:53 +0100
commita64ce9f2e9c13b8f644bd75800ee6b1cd9942066 (patch)
treeccaffc933e870368b04083970d38eabc64548789 /public
parent3203db9d2b47d0ac86c74829193f6e53e5eb76a8 (diff)
edit model name
Diffstat (limited to 'public')
-rwxr-xr-xpublic/javascripts/toxcreate.js57
1 files changed, 57 insertions, 0 deletions
diff --git a/public/javascripts/toxcreate.js b/public/javascripts/toxcreate.js
index aef0455..493168f 100755
--- a/public/javascripts/toxcreate.js
+++ b/public/javascripts/toxcreate.js
@@ -95,6 +95,63 @@ $(function() {
}
});
+jQuery.fn.editModel = function(type, options) {
+ var defaults = {
+ method: 'get',
+ action: this.attr('href'),
+ trigger_on: 'click'
+ };
+ var opts = $.extend(defaults, options);
+ this.bind(opts.trigger_on, function() {
+ $.ajax({
+ type: opts.method,
+ url: opts.action,
+ dataType: 'html',
+ data: {
+ '_method': 'get'
+ },
+ success: function(data) {
+ $("div#model_" + opts.id + "_name").html(data);
+ $("input#model_" + opts.id + "_name").focus();
+ },
+ error: function(data) {
+ alert("model edit error!");
+ }
+ });
+ return false;
+ });
+};
+
+jQuery.fn.saveModel = function(type, options) {
+ var defaults = {
+ method: 'put',
+ action: 'model/' + options.id,
+ trigger_on: 'click'
+ };
+ var opts = $.extend(defaults, options);
+
+ this.bind(opts.trigger_on, function() {
+ var name = $("input#model_" + opts.id + "_name").val();
+ $.ajax({
+ type: opts.method,
+ url: opts.action,
+ dataType: 'html',
+ data: {
+ '_method': 'put',
+ 'name': name
+ },
+ success: function(data) {
+ $("div#model_" + opts.id + "_name").html(data);
+ },
+ error: function(data) {
+ alert("model save error!");
+ }
+ });
+ return false;
+ });
+};
+
+
jQuery.fn.deleteModel = function(type, options) {
var defaults = {
method: 'post',