Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#7201 closed bug (notabug)

Whitespace between </div> and following <div> tag results in error in jquery

Reported by: edoloughlin Owned by:
Priority: minor Milestone: 1.9.0
Component: ui.dialog Version: 1.8.11
Keywords: Cc:
Blocked by: Blocking:

Description

This works:

    $('<div><p>Some Text</p></div><div><p>Some other Text</p></div>').dialog()

but if you put whitespace between the closing DIV tag and the next DIV tag it causes an error in jQuery code:

    $('<div><p>Some Text</p></div> <div><p>Some other Text</p></div>').dialog()

The above causes the following error in jquery-1.4.2.js:5464

    TypeError: Result of expression 'this[i].style' [undefined] is not an object.

Change History (5)

comment:1 Changed 9 years ago by Scott González

Resolution: invalid
Status: newclosed

You're creating a text node by placing that space between the elements and then trying to initialize a dialog against the text node. I'm not sure that this is even a valid use of jQuery.

comment:2 Changed 9 years ago by rdworth

Neither of them are valid. An html string passed to jQuery can only contain one top-level node.

comment:3 in reply to:  1 ; Changed 9 years ago by edoloughlin

Replying to scott.gonzalez:

You're creating a text node by placing that space between the elements and then trying to initialize a dialog against the text node. I'm not sure that this is even a valid use of jQuery.

This isn't exactly the code I'm using. I'm actually using the jQuery Template plugin:

   $.tmpl('template-name').dialog()

The string identified by 'template-name' has whitespace because I'm using a heredoc in Coffeescript to make it readable.

This seemed valid to me - it's similar to the examples in the Nimikor Blog pointed to by the Dialog docs on the jQueryUI site.

comment:4 in reply to:  3 ; Changed 9 years ago by rdworth

You need to wrap your two DIVs in another DIV

comment:5 in reply to:  4 Changed 9 years ago by edoloughlin

Replying to rdworth:

You need to wrap your two DIVs in another DIV

Oops! Thanks.

Note: See TracTickets for help on using tickets.