开发者

jquery-in-place-editor pre post hooks?

开发者 https://www.devze.com 2023-01-07 23:07 出处:网络
I\'m using jquery edit in place lib and I\'m having a problem when trying to use a class selector to select multiple editable items.

I'm using jquery edit in place lib and I'm having a problem when trying to use a class selector to select multiple editable items.

I'm calling editInPlace on an array of elements so I don't have to repeat that call for each editable item.

What I can't figure out is how to append the item id to the url. I'm using rails so I need a url like tags/10

Do you know how to dynamically alter the url or params for each editable item? I tried using the callback param but that cancels the ajax request.

html:

<li class="tag" id="tag_1">bright light</li>
<li class="tag" id="tag_2">soft light</li>

jQuery:

$('.tag').editInPlace({
  url:"/tags/" // NEED TO ADD THE ASSET ID TO THE URL example /tags/10
});
开发者_StackOverflow社区


You can use .each(), like this:

$('.tag').each(function() {
  $(this).editInPlace({
    url:"/tags/" + this.id.replace('tag_','')
  });
});

This just takes the ID and removes the tag_ portion via .replace() before appending it.

0

精彩评论

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