Bug Tracker

Changes between Initial Version and Version 4 of Ticket #12874


Ignore:
Timestamp:
Nov 29, 2012, 1:05:58 PM (9 years ago)
Author:
jaubourg
Comment:

Does this work without using r.js? In which case it's a bug in r.js, not jQuery.

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #12874

    • Property Owner set to [email protected]
    • Property Status changed from new to pending
    • Property Component changed from unfiled to deferred
    • Property Priority changed from undecided to low
  • Ticket #12874 – Description

    initial v4  
    11Hi,
     2
    23I am working on a site and I am using backbonejs and requirejs and with r.js I create a bundled js file which contains all my js modularised.
    34
    45If I make a simple ajax request and I even don't attach any event listener on it I get the following error after I receive the ajax response:
     6
     7{{{
    58Uncaught ReferenceError: add is not defined
    69jQuery.Callbacks.self.add.firingLength
     
    1215done
    1316jQuery.support.ajax.jQuery.ajaxTransport.send.callback
     17}}}
    1418
    1519I have made some debugging and it seems that the problem is here:
     20{{{#!js
    1621// First, we save the current length
    17                                         var start = list.length;
    18                                         (function add( args ) {
    19                                                 jQuery.each( args, function( _, arg ) {
    20                                                         var type = jQuery.type( arg );
    21                                                         if ( type === "function" && ( !options.unique || !self.has( arg ) ) ) {
    22                                                                 list.push( arg );
    23                                                         } else if ( arg && arg.length && type !== "string" ) {
    24                                                                 // Inspect recursively
    25                                                                 add( arg );
    26                                                         }
    27                                                 });
    28                                         })( arguments );
     22var start = list.length;
     23(function add( args ) {
     24        jQuery.each( args, function( _, arg ) {
     25                var type = jQuery.type( arg );
     26                if ( type === "function" && ( !options.unique || !self.has( arg ) ) ) {
     27                        list.push( arg );
     28                } else if ( arg && arg.length && type !== "string" ) {
     29                        // Inspect recursively
     30                        add( arg );
     31                }
     32        });
     33})( arguments );
     34}}}
    2935
    3036This is in jquery.js at line 997.
     37
    3138It seems that the recursive call of the add method is not working.
     39
    3240This is how I made the ajax request:
     41{{{#!js
    3342$.ajax(baseUrl+'query',{
    34                 data:form.serialize(),
    35                 dataType: 'json',
    36                 type: 'post'
    37             });
     43        data:form.serialize(),
     44        dataType: 'json',
     45        type: 'post'
     46});
     47}}}