如果警报被注释掉,则jquery函数不起作用

时间:2012-11-01 22:51:16

标签: jquery jeditable

我正在运行一个post函数,然后函数结束。我正在运行另一个功能。问题是第二个函数不起作用,如果我在函数中没有警报消息,它就不会运行...

jquery函数是:

function applyeditable(){
    //alert('trying to apply editable class...');

$(".edit_mystatus").editable('/cgi-bin/my_cgi_script.pl', {
event       : 'dblclick',       //or dblclick
data        : " {'A':'Active','C':'Completed','D':'Deleted'}",
type        : 'select',
submit      : 'Ok',
indicator   : '<img src="http://my_website/images/indicator.gif">',
placeholder : 'Double Click to Edit',
tooltip     : 'Double Click to edit...',
style       : 'display: inline',
name        : 'name',
id          : 'id',
callback    : function(value, settings) {
                // console.log(this);
                // console.log('returned value= '+value+' we have to now disable rest of form if Completed or Deleted');
                // console.log(settings);
                }
});
$(".edit_mynotes").editable('/cgi-bin/my_cgi_script.pl', {
    event       : 'dblclick',       //or dblclick
    type        : 'textarea',
    rows        : 10,
    cols        : 100,
    cancel      : 'Cancel',
    submit      : 'Save',
    indicator   : '<img src="http://my_website/images/indicator.gif">',
    placeholder : 'Double Click to enter text',
    tooltip     : 'Double Click to edit...',
    style       : 'display: inline',
    name        : 'name',
    id          : 'id'
});
$(".ajaxfileupload").editable('/cgi-bin/my_cgi_script.pl', {
    type        : 'ajaxupload',
    submit      : 'Upload',
    cancel      : 'Cancel',
    indicator   : '<img src="http://my_website/images/indicator.gif">',
    tooltip     : "Double Click to upload...",
    style       : 'display: inline',
    name        : 'filename',
    id          : 'id'
});

$(".checkclass").click(function() {
    var $this = $(this);
    // $this will contain a reference to the checkbox
    var chkboxval = $this.val();
    if ($this.is(':checked')) {
        alert('the checkbox was checked val='+chkboxval);
    } else {
        alert('the checkbox was UNchecked val='+chkboxval);
    }
});
}

html是:

<input type="checkbox" class="checkclass" value="1_0">
<input type="checkbox" class="checkclass" value="1_1">
<input type="checkbox" class="checkclass" value="1_2">

...

1 个答案:

答案 0 :(得分:0)

必须从调用函数的最内层'on success'事件调用applyedable函数。这将照顾事物的异性。

例如:

callingfunction(ABC){ ... ...

$.get(data, function(myfile) {
$("#someid").html(myfile);
applyeditable()     //this call runs after above is success (100% execution)
});

... }