Skip to main content

Search and Top Navigation

#7201 closed bug (notabug)

Opened March 25, 2011 03:16PM UTC

Closed March 25, 2011 03:38PM UTC

Last modified March 25, 2011 03:54PM UTC

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.
Attachments (0)
Change History (5)

Changed March 25, 2011 03:38PM UTC by scottgonzalez comment:1

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.

Changed March 25, 2011 03:42PM UTC by rdworth comment:2

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

Changed March 25, 2011 03:49PM UTC by edoloughlin comment:3

Replying to [comment:1 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.

Changed March 25, 2011 03:51PM UTC by rdworth comment:4

You need to wrap your two DIVs in another DIV

Changed March 25, 2011 03:54PM UTC by edoloughlin comment:5

Replying to [comment:4 rdworth]:

You need to wrap your two DIVs in another DIV

Oops! Thanks.