Brained Washed
Brained Washed

Reputation: 703

why is that my jquery dialog wont pop out?

I don't know what is wrong why my dialog won't pop up because when I try pop outing the form from the html it works fine but from with this jquery table generated it won't . So what will i do?

success: function(data){
            var toAppend = '';

            toAppend += '<thead><tr><th>Name</th><th>Image</th><th>Price</th></tr></thead>';
            toAppend += '<tbody>';

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

                toAppend += '<tr><td><p>'+

                data[i]['product_name'][0]+'</p></td><td><a href="#">'+

                <img id="size" src="'+data[i]['image'][0]+'" alt="">+'</a></td><td>'+

                data[i]['price'][0]+'</td></tr>';
            }

            toAppend += '</tbody>';

            $('.data-results').append(toAppend);
        }

here's the calling the dialog function

$('#size').click(function() {
    $('#dialog').dialog({
        resizable: false,
        modal: true
    });
});

Upvotes: 0

Views: 62

Answers (2)

deerua
deerua

Reputation: 408

rename id="size" to class="size", because parameter "id" must be unique for each element

$('.size').live("click",function() {
    $('#dialog').dialog({
        resizable: false,
        modal: true
    });
});

Upvotes: 1

Ohgodwhy
Ohgodwhy

Reputation: 50798

You already have an iterator.

<img id="size-"+i

Change your click selector -

$('img[id^=size]').click(function(){ 
    $('#dialog').dialog({
        resizable: false,
        modal: true
    });
});

Upvotes: 1

Related Questions