I have the following jQuery code using jQuery UI
EDIT:
$(document).ready(function(){
$('#the-link-2').click(function(){
var array = ["test1","test2","test3","test4"]
var i = 1;
while (i<array.length) {
var newDiv = $(document.createElement('div'));
$(newDiv).html(array[i]).dialog({
buttons: {
'Previous': function() {
$(this).dialog("close");
i--;
},
'Next': function() {
$(this).dialog("close");
i++;
}
}
}
});
});
});
I am trying to loop through the items of the array (starting with item #1). The dialog box displays the item and moves to the previous/next item depending on which button the user clicks. It does not work (nothing gets fired). If I remove the "while" loop I do get the dialog box with the #1 item. Could anyone give me the right syntax to obtain the desired result please? Thanks.