Multiple Dialogs (Modal Box)
Hello all,
I'm pretty new with jquery and I looked for information and I found
some code that works for static amount of modal boxes. But now I want
it to be dynamic.
Static Method:
$(function() {
var options = {
autoOpen: false,
width: 'auto',
modal: true
};
$([1, 2, 3]).each(function() {
var num = this;
var dlg = $('#dialog-player-' + num).dialog(options);
$('#player-link-' + num).click(function() {
dlg.dialog("open");
return false;
});
});
});
Dynamic Method:
$(function() {
var options = {
autoOpen: false,
width: 'auto',
modal: true
};
$("div#parent div").each(function() {
var num = this;
var dlg = $('#dialog-player-' + num).dialog(options);
$('#player-link-' + num).click(function() {
dlg.dialog("open");
return false;
});
});
});
I looked at this page of the documentation: http://docs.jquery.com/Core/each
What I tried is to select all divs in container "div#parent". But that
didn't work. Anybody know of any other way to do this ?