jEditable新值未设置

时间:2011-10-18 13:07:47

标签: jquery jeditable

当我触发jeditable时,我想将初始textarea值设置为空字符串,因此:

function wireupTagInPlaceEditing() {
    $('.newtag-editable-target').editable(submitTagEdit, {
        event: 'tagthumbnailnewtag',
        type: 'textarea',
        submit: 'Ok',
        cancel: 'Cancel',
        cssclass: 'tag-inplace-textarea-edit'
    });

    $('.newtag-editable-target').click(function () {
        $(this).trigger('tagthumbnailnewtag');
        $(this).find('textarea').val('');
    });
}
function submitTagEdit(value, settings) {
    alert('tag edit complete ' + value);
}

但是,在编辑完成后,值为空(即使我输入了某些内容)。我是否需要做一些特殊的事情来连接值和设置参数?我正在使用jeditable 1.7.1

修改 我的HTML片段:

<ul><li><div class="tagtitle">Machine</div><div class="tagtext" tagkey="xx8REtGOuEiPGwRuTxtC7w==">Articulated Truck</div></li><li><div class="tagtitle">Machine</div><div class="tagtext" tagkey="93yW9fJP7EeHwmPhKVcXLw==">Backhoe Loader</div></li><li><div class="tagtitle">Machine</div><div class="tagtext" tagkey="/lYmf80zA0u1UBpP9fYwjg==">Cold Planers</div></li><li><div class="tagtitle">Machine</div><div class="tagtext" tagkey="QRK9mI5xlkaWVD1EgSd48A==">Compactors</div></li><li><div class="tagtitle">Machine</div><div class="tagtext" tagkey="s9ckJ+/41U+xU+OZ2vQGvA==">Compact Track and Multi-terrain Loader</div></li><li><div class="tagtitle">Machine</div><div class="tagtext" tagkey="wtdp/loQp0e00akaU3hIvw==">Feller Buncher</div></li><li><div class="tagtitle">Machine</div><div class="tagtext" tagkey="zsaNLg3640ill5KBTJ3QVQ==">Forest Machines</div></li><li><div class="tagtitle">Machine</div><div class="tagtext" tagkey="rungSduACkqkoMKR0JKl0Q==">Forwarders</div></li><li><div class="tagtitle">Machine</div><div class="tagtext" tagkey="Qjez3j0CAE26gTbUf9CbJg==">Harvesters</div></li><li><div class="tagtitle">Machine</div><div class="tagtext" tagkey="B6JDNj8HD0yNaSHT5asKMQ==">Hydraulic Excavators</div></li><li><div class="tagtitle">Machine</div><div class="tagtext" tagkey="Ib9gJT8zBkmoVB3KM0eQSw==">Industrial Loaders</div></li><li><div class="tagtitle">Machine</div><div class="tagtext" tagkey="2782jTgXCEevbAsqm1rSnw==">Knuckleboom Loaders</div></li><li><div class="tagtitle">Machine</div><div class="tagtext" tagkey="9dCpblCyxUe4v2Hx8/4ufQ==">Material Handlers</div></li><li class="clickfornewtag"><div class="tagtitle">Machine</div><div class="tagtext newtag-editable-target">click here to add a new Machine tag</div></li></ul>

EDIT2 以下修正案有效:

$('.newtag-editable-target').click(function () {
        $(this).trigger('tagthumbnailnewtag');
        setTimeout(function () {
            $('.newtag-editable-target').find('textarea').val('');
        }, 1);
    });

不知道发生了什么。

1 个答案:

答案 0 :(得分:0)

尝试在submitTagEdit函数中返回值:

function submitTagEdit(value, settings) {
    alert('tag edit complete ' + value);
    return value;
}