简体   繁体   中英

Many jquery ui dialogs

Im trying to show more dialogs depending of the size of my newsArray. Why isnt it working?, i just get 1 popup. I checked the array and its 7 items in it

                for(var i=0; i<newsArray.length; i++{

                            $("#dialog").dialog({

                                      resizable: true,
                                      width:"auto",
                                      modal: true,
                                      title:"test"    
                             });    
                 }

Use class instead of using Id for dialog initialisation. Moreover you cannot have multiple elements of same Id (if any)

Demo: http://jsfiddle.net/lotusgodkk/GCu2D/58/

Code:

<div class="checked" >Click to open dialog</div>
<div class="checked" >Click to open dialog</div>
<div class="checked" >Click to open dialog</div>
<div class="checked" >Click to open dialog</div>
<div class="checked" >Click to open dialog</div>
<div class="checked" >Click to open dialog</div>
<div class="checked" >Click to open dialog</div>
<div class="checked" >Click to open dialog</div>

Javascript:

$(document).ready(function () {
for (var i = 0; i < 7; i++) {
    $(".checked").dialog({
        resizable: true,
        width: "auto",
        modal: true,
        title: "test"
    });
  }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM