Bug Tracker

Opened 5 years ago

Closed 5 years ago

#11444 closed bug (invalid)

Issue with .live() and .filter()

Reported by: winterwind Owned by: winterwind
Priority: low Milestone: None
Component: event Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:

Description

Using the following code snippet I was triggering the error " Syntax error, unrecognized expression: false; }); " - this error was happening as I changed a select that was returning true to the .filter().

(function($) {

$(document).ready(function() {

$('select').filter(function() {

if($(this).attr('name').match(/option\[\d+\]\[TYPE\]$/)) {

return true;

} return false;

}).live('change', function() {

alert('here');

});

});

})(jQuery);

The same bit of code works find with .bind() however.

jQuery versions tested: 1.7.1, 1.7.0, 1.6.1, 1.5.1 - all cause the issue, all work fine with .bind() instead.

Change History (3)

comment:1 Changed 5 years ago by winterwind

Using the following code snippet I was triggering the error " Syntax error, unrecognized expression: false; }); " - this error was happening as I changed a select that was returning true to the .filter().

(function($) {
    $(document).ready(function() {
        $('select').filter(function() {
            if($(this).attr('name').match(/^option\[\d+\]\[TYPE\]$/)) {
                return true;
            }
            return false;
        }).live('change', function() {
            alert('here');
        });
    });
})(jQuery);

The same bit of code works find with .bind() however.

jQuery versions tested: 1.7.1, 1.7.0, 1.6.1, 1.5.1 - all cause the issue, all work fine with .bind() instead.

comment:2 Changed 5 years ago by addyosmani

  • Component changed from unfiled to event
  • Owner set to winterwind
  • Priority changed from undecided to low
  • Status changed from new to pending

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket!

Additionally, be sure to test against the "jQuery (edge)" version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to begin.

Last edited 5 years ago by addyosmani (previous) (diff)

comment:3 Changed 5 years ago by dmethvin

  • Resolution set to invalid
  • Status changed from pending to closed

As documented, .live cannot be changed. And it is deprecated.

Version 0, edited 5 years ago by dmethvin (next)
Note: See TracTickets for help on using tickets.