![]() |
Problems using Tabs in a Dialog populated from a Template
Hi all,
I am attempting to use three jQuery plugins to render some templated content that should include tabs within a dialog. I am using jQuery.tmpl() for the template along with Tabs and Dialog from jQuery UI. The problem I have is to do with context in that setting the selector to an id of the <div> to make tab-able only works on the first attempt. To understand what I am on about, please check out the following code which is missing the references to jquery.js, jquery-ui.js and jquery.tmpl.js: Code:
<script id="tabTemplate" type="text/x-jquery-tmpl">Any advice on what else I could try would be appreciated! Thanks, Marc |
Not familiar with the template function you're using, but it looks like you're reloading #tabTemplate, and your reloaded content doesn't have the click event attached.
.live() should do the trick: Code:
$('#dialogButton').live('click',function () { etc |
Without tmpl()
Hi,
Thanks but it is not the click() event that is firing incorrectly. It is the rendering of the dialog contents into tabs that is the problem. This may be replicated without using the tmpl() plugin as follows: Code:
<div id="tabs"> |
Been playing about with this for a while, but I'm not sure I fully understand what it is you're trying to do. On clicking the dialogify button this should create a dialog with tabbed content, which is copied from #tabs (here as a normal div, but otherwise as a template) - is that right?
The problem I'm seeing is that because #tabs is cloned, the divs containing the tabbed content are also cloned and hence there are multiple divs with the same id including tab content - so the tabs in the dialog don't work. Is that the problem? Or am I way off beam? |
Hi,
No, that is the problem exactly. Thanks for looking into this on a miserable morning in West Yorkshire! Marc |
OK, have a try with:
Code:
<div class="tabs">html:I changed the id on the template to a class and added a content class to the content divs just to make things easier to manipulate. This seems to work for me OK. It also seems ever so slightly clunky... What else is there to do on a wet Saturday? Are you in WY too then? |
Thanks
Excellent, that's exactly what I was after due to the problems with multiple identical ids. To get this working with tmpl() I've used the following:
Code:
<script id="tabTemplate" type="text/x-jquery-tmpl">Thanks again. |
| All times are GMT +1. The time now is 02:33 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.