Delmon Young
Delmon Young

Reputation: 2053

jQuery namespace is not a function

Everytime I try to run the following code I get a:

.call is not a function

I can't figure out what is going on as this is a pretty straightforward piece of code. I must be missing something really obvious here. Thanks for the help. If possible please try to include code samples still learning here.

;(function($){

$.fn.call = function() { 

var CLICK = 'click';

function ClickCall(event) {
    var $call = $(event.target).closest('.call-survey');

     if ($call.find('#yes').is(':checked')) {
         $call.find('.call-survey fieldset').hide();
     } else {
         $call.find('div.call-survey-no').show();
         $call.find('#yes').addClass('left');

     }
}

return this.each(function() {
        var $call = $(this);
        $call.on(CLICK, '#chatForm', ClickCall);
});

};
})(jQuery);

$(document).ready(function () { $('.call-survey').call(); });

Upvotes: 0

Views: 465

Answers (1)

Daniel A. White
Daniel A. White

Reputation: 190942

call is a reserved name in JavaScript. It has to do with call and apply with functions.

I suggest changing it.

Upvotes: 1

Related Questions