jquery-in-place-editor pre post hooks?
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.
精彩评论