开发者

jeditable edit multiple links

Trying to make jeditable to edit multiple links, and update results onsubmit

function inlineEditData(linkId){
    $('.inlineLinkEdit_' + linkId).editable('crudDocumentationLink.htm', {  
        event     : 'editclick',
        submit    : 'Save',
        cancel    : 'Cancel',
        indicator : '<img src="images/indicator.gif">',
开发者_运维技巧        width     : 600,
        onsubmit  : function(value, settings) {
            $('.inlineLink_' + linkId).href=value;
            $('.inlineLink_' + linkId).innerHTML=value;
            $('.inlineLink_' + linkId).show();
            $('.inlineLinkEdit_' + linkId).hide();
            $('.inlineLinkTrigger_' + linkId).show();
        },
        onreset  : function(value, settings) {
            $('.inlineLink_' + linkId).show();
            $('.inlineLinkEdit_' + linkId).hide();
            $('.inlineLinkTrigger_' + linkId).show();
        }
    });
}

function editLink(linkId){
    $('.inlineLink_' + linkId).hide();
    $('.inlineLinkEdit_' + linkId).show();
    $('.inlineLinkTrigger_' + linkId).hide();

    inlineEditData(linkId);

    $('.inlineLinkEdit_' + linkId).trigger('editclick');
}

And html:

<a href="${document.link}" class="inlineLink_${document.id}" id="inlineEdit_${document.id}">${document.link}</a>
<span style="display:none;" class="inlineLinkEdit_${document.id}" id="inlineEdit_${document.id}">${document.link}</span>
<span class="inlineLinkTrigger_${document.id}" onclick="editLink(${document.id})" style="cursor:pointer;">edit</span>

Editing working. But i want that value on the page updated according to user input. So what is wrong in my code?


Finally i managed to do it (problem was in setting text correctly). I changed "onsubmit" to "callback" and first two lines inside it.

$('.inlineLink_' + linkId).attr({"href":$('.inlineLinkEdit_' + linkId).text()});
$('.inlineLink_' + linkId).text($('.inlineLinkEdit_' + linkId).text());
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜