-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Simple way to init inserted elements #1799
Comments
We completely agree that we need an easy way to enhance appended markup. It's a tricky thing to get right so we've been kicking around ideas internally on this. On our radar for sure. |
Thanks for the idea! I think what we'll end up doing is something along the lines of this (currently in the decoupled widgets branch): df92fbd It'd work like this: I'm going to move this to the feature requests wiki. Thanks! |
!!!!!!!awesome! been waiting for this... |
@scottjehl: that syntax looks good to me. I look forward to seeing that get into a release. @toddparker: while you guys are discussing / implementing, in the meantime, could you please point me towards a resource that can show me the manual way of enhancing appended markup? This is blocking me from continuing forward development. Thanks guys. |
You can call the specific plugins (slider, collapsible, etc.) manually on the markup you're injecting. If you're adding/removing content from an existing widget like a listview or select, call the refresh() method on it. |
@toddparker: having more than a general explanation would be useful to me, and probably useful to many others while we workaround this issue. Specific examples?
(Coincidentally, the above doesn't work for me) |
So, you'll want to use the :jqmData(...) selector for one, just in case there's namespacing on the data attrs, but basically, you can check the top of all of the widgets in this commit for the particulars. We plan to get these documented ASAP as well. |
@scottjehl: So I checked out the All in all, much better than before. Thank you!! |
It seems to work only partly for me; I checked out this branche and I'm running this code: $('#wordpress').live('pagecreate',function(event){ '+ this.title +''+ this.excerpt +' }); }); return false; }); But only ua-link seems to be enhanced afterwards, the rest of the styles aren't. It's probably something I'm doing wrong myself, but I can't see what. Also, @toddparker, which refresh() method are you referring to? This might apply better to my situation. |
Is it possible to put the ul element in the dom already, then stuff the inner html, then call the refresh on the ul element? |
This might be a shortcut as well..... |
@scottjehl: is there a timeline for merging |
There needs to be a simple way init everything, and that init needs to be idempotent (something similar to FB.XFBML.parse).
If I were to do something like this:
Ideally, jQuery Mobile should automatically handle this and parse it. But I understand that may be difficult in all cases (replace/insert/append/etc). So I should at least be able to do something like:
Better yet, I should be able to do something like this:
The text was updated successfully, but these errors were encountered: