Skip to main content

Search and Top Navigation

#6887 closed bug (notabug)

Opened January 22, 2011 05:41AM UTC

Closed January 24, 2011 02:04PM UTC

triggered twice with emebedded script tag problem

Reported by: ling Owned by:
Priority: minor Milestone: 1.9.0
Component: ui.dialog Version: 1.8.8
Keywords: Cc:
Blocked by: Blocking:
Description

When I load the content of /test/anycontent.php

<div>
    <h1>My title</h1>
    <p>This is a paragraph</p>
    <script type="text/javascript">
//        alert("it seems that the presence of script tags is enough to trigger the problem");
    </script>
</div>

into jquery ui dialog, the result is buggy using the $.post method,

and clean using the load method.

Here is the test with post method

$("#test").click(function(e){
           $.post(url, {}, function(data){
                $(data).dialog();
            });
        });

And here the test with get method

 $("#test").click(function(e){
            $("<div></div>").load(url).dialog();
        });

Then my problem is that with the post method,

I will have 2 instances of ui-dialog !!

only one was expected, the other is just in the middle of the first one,

and it is empty and closed.

Do you know why ?

Do you know issues for this ?

Attachments (0)
Change History (3)

Changed January 24, 2011 06:37AM UTC by shrage.smilowitz comment:1

For some reason (dont know why) if you pass in html elements in a jquery selector liek this $(<div><script></script></div> it will return them as a list of results div as item1 and script as item2

The dialog function (also for some reason i don't know) runs an each function of the selectors results, for each item in the selector it will create a dialog. so it will create a dialog for the normal html elements of your data and for the script element. what i'm doing is this:

var all = $(data);

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

if (all[i].tagName == "SCRIPT") {

$("body").append(all[i]); //If i don't append it to the body it wont evaluate the script

}

else {

$(all[i]).dialog();

}

}

Changed January 24, 2011 06:54AM UTC by ling comment:2

Replying to [comment:1 shrage.smilowitz]:

For some reason (dont know why) if you pass in html elements in a jquery selector liek this $(<div><script></script></div> it will return them as a list of results div as item1 and script as item2 The dialog function (also for some reason i don't know) runs an each function of the selectors results, for each item in the selector it will create a dialog. so it will create a dialog for the normal html elements of your data and for the script element. what i'm doing is this: var all = $(data); for (i = 0; i < all.length; i++) { if (all[i].tagName == "SCRIPT") { $("body").append(all[i]); //If i don't append it to the body it wont evaluate the script } else { $(all[i]).dialog(); } }

Thank you, I did it a similar way too.

Changed January 24, 2011 02:04PM UTC by scottgonzalez comment:3

resolution: → invalid
status: newclosed

This is not a bug in jQuery UI. Please use the forums for help.