开发者

jquery jeditable without OK and Cancel Buttons

开发者 https://www.devze.com 2022-12-22 01:58 出处:网络
I have a textarea that I\'m able to edit with the jeditable plugin but I do not want the OK and Cancel buttons. I am, instead, going to save the text by clicking away from the textarea (blur). I have

I have a textarea that I'm able to edit with the jeditable plugin but I do not want the OK and Cancel buttons. I am, instead, going to save the text by clicking away from the textarea (blur). I have that code ready to go but I do not know how to make it wo开发者_StackOverflow中文版rk.


Simply add this to the hash with the settings:

onblur   : 'submit'

Example:

$(document).ready(function() {
    $("#editable1").editable("http://www.domain.com/editdata/", { 
        indicator : "<img src='img/indicator.gif'>",
        type      : 'textarea',
        onblur    : 'submit',
        tooltip   : 'Click to edit...',
        cancel    : 'Cancel'
    });
});

Hope it helps,

Cheers


For those that might be struggling with mobile support due to onblur being triggered prematurely, and need a programmatic way to "cancel" the edit. I added the snip-it below to the start of the jquery.jeditable.js file, under the if('destroy' == target) block.

if ('cancel' == target) {
        //original.reset();
        if ($.isFunction($.editable.types[settings.type].reset)) {
            var reset = $.editable.types[settings.type].reset;
        } else {
            var reset = $.editable.types['defaults'].reset;
        }
        reset.apply(form, [settings, original]);
        return;
    }

It wouldn't be to difficult to modify this into a submit function as well.

0

精彩评论

暂无评论...
验证码 换一张
取 消