Bug Tracker

Modify

Ticket #11444 (closed bug: invalid)

Opened 2 years ago

Last modified 2 years ago

Issue with .live() and .filter()

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

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

comment:1 Changed 2 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 2 years ago by addyosmani

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

Thanks for submitting a ticket to the jQuery bug tracker. Could you please comment back with a complete test case on jsFiddle.net reproducing the issue experienced?.

Version 0, edited 2 years ago by addyosmani (next)

comment:3 Changed 2 years ago by dmethvin

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

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

Last edited 2 years ago by dmethvin (previous) (diff)

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.