Skip to main content

Bug Tracker

Side navigation

#6382 closed bug (fixed)

Opened March 31, 2010 04:13PM UTC

Closed January 17, 2011 01:47PM UTC

.live() not working properly with "has attribute" css selector

Reported by: cjoudrey Owned by:
Priority: low Milestone: 1.4.3
Component: selector Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:
Description

There appears to be a problem with .live() and "has attribute" css selector when using forms.

Using the following HTML:

<span title="test">1234</span>
<form>
    <input type="text" name="title" />
</form>

When you run $('[title]'), the span element is returned.

However, if you use the following:

$('[title]').live('click', function() {
    alert('clicked a [title]');
});

When you click on the input an alert occurs. The selector [title] returns the <form>.

Reproduced in Firefox 3.6.

Attachments (0)
Change History (5)

Changed April 02, 2010 02:54AM UTC by dmethvin comment:1

This is actually due to the fact that the names of input elements become properties of the form that contains them.

http://yura.thinkweb2.com/domlint/

Changed November 15, 2010 03:14AM UTC by dmethvin comment:2

priority: → undecided
status: newopen

Changed January 12, 2011 10:49PM UTC by anonymous comment:3

I think I'm understanding the question correctly, but was not able to replicate the problem here: http://jsfiddle.net/dBsr4/

Clicking on the second input does not return the 'item clicked' alert.

Changed January 12, 2011 11:53PM UTC by cjoudrey comment:4

I am also unable to replicate the problem now. Maybe it got fixed. The issue can be closed.

Changed January 17, 2011 01:47PM UTC by jitter comment:5

description: There appears to be a problem with .live() and "has attribute" css selector when using forms. \ \ Using the following HTML: \ \ <span title="test">1234</span> \ <form> \ <input type="text" name="title" /> \ </form> \ \ When you run $('[title]'), the span element is returned. \ \ However, if you use the following: \ \ $('[title]').live('click', function() { \ alert('clicked a [title]'); \ }); \ \ When you click on the input an alert occurs. The selector [title] returns the <form>. \ \ Reproduced in Firefox 3.6.There appears to be a problem with .live() and "has attribute" css selector when using forms. \ \ Using the following HTML: \ {{{ \ <span title="test">1234</span> \ <form> \ <input type="text" name="title" /> \ </form> \ }}} \ When you run $('[title]'), the span element is returned. \ \ However, if you use the following: \ {{{ \ $('[title]').live('click', function() { \ alert('clicked a [title]'); \ }); \ }}} \ \ When you click on the input an alert occurs. The selector [title] returns the <form>. \ \ Reproduced in Firefox 3.6.
milestone: → 1.4.3
priority: undecidedlow
resolution: → fixed
status: openclosed

Closing as requested by the reporter. Fixed in 1.4.3