x1nick Posted August 22, 2009 Share Posted August 22, 2009 Just trying to get to grips with jQuery, and while I have ajax etc working fine. I can't get dialog boxes to work how I want. Basically I have a list, each item has a update option. When clicked I would like a dialog box to open to request confirmation. I have created a div for the message box <div id="dialog" title="Update Template"></div> With this I need to fill the content of the div with a message such as 'Are you sure you want to update "##templatename##"?' The code that currently is the button is <a href="#" title="Update Template" id="update">Update</a> And the jquery config <script type="text/javascript"> $(function(){ // Dialog $('#dialog').dialog({ autoOpen: false, width: 600, modal: true, buttons: { "Ok": function() { $(this).dialog("close"); }, "Cancel": function() { $(this).dialog("close"); } } }); $('#update').click(function(){ $('#dialog').dialog('open'); return false; }) }); </script> Im still learning javascript so not too sure if I could use an associative array somehow. So each item would be [templateid][templatename] Then the message box be given the template id and extract the template name from the array Any help on this would be really appreciated. Quote Link to comment Share on other sites More sharing options...
x1nick Posted August 22, 2009 Author Share Posted August 22, 2009 After playing some more I tried this onclick="$.tplid = '<?=$result['tplid']?>';$.message = 'Are you sure you want to update the template \'<?=$result['tplname']?>\'?';" Added that into the link on the list And updated the jquery config to $('#update').click(function(){ $('#dialog').html($.message); $('#dialog').dialog('open'); return false; }) Which seems to work. Now I don't know how to make this work for multiple lines of data. As I have anything from 1-100 rows of data being shown each one will need a unique id, how would I edit the code above to cope with this? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.