Hello I am trying to pass array data into the jquery dialog box and display. I haven’t had much luck with this and Im guessing my whole approach to this is wrong. Any guidance to the right way is much appreciated.
<html>
<div id="confirm"></div>
</html>
<script>
var array_data = ["London", "NewYork", "Miami" , "LosAngeles"];
$('#confirm').html(array_data).dialog({
autoOpen: false,
modal: true,
title: 'Confirmation message',
buttons: {
Submit: function () { //Do Something here };
Cancel: function () { $(this).dialog("close"); }
},
width: 850, height: 300
}).dialog('open');
</script>
I’m unable to figure out how I would pass the array object to the modal and then print out the array values one by one.
If you are planning to print out the array values on open of the dialog, then, you may attach an open event to the dialog. You may want to check out: http://api.jqueryui.com/dialog/#event-open
So in your case, you may do it this way: