user2445971
user2445971

Reputation: 87

Javascript: Uncaught TypeError: object is not a function

I have this piece of code:

$(document).ready( function(){
$(".cb-enable").click(function(){
    $("#repetitive").show();
    var parent = $(this).parents('.switch');
    $('.cb-disable',parent).removeClass('selected');
    $(this).addClass('selected');
    $('.checkbox',parent).attr('checked', true);
    $("#repetitiveHidden").empty();
    $("#repetitiveHidden").val("true");
});
$(".cb-disable").click(function(){
    $("#repetitive").hide();
    var parent = $(this).parents('.switch');
    $('.cb-enable',parent).removeClass('selected');
    $(this).addClass('selected');
    $('.checkbox',parent).attr('checked', false);
    $("#repetitiveHidden").empty();
    $("#repetitiveHidden").val("false");
});
$(".overnight-enable").click(function(){
    var parent = $(this).parents('.switch');
    $('.overnight-disable',parent).removeClass('selected');
    $(this).addClass('selected');
    $('.checkbox',parent).attr('checked', true);
    $("#overnightHidden").empty();
    $("#overnightHidden").val("true");
});
$(".overnight-disable").click(function(){
    var parent = $(this).parents('.switch');
    $('.overnight-enable',parent).removeClass('selected');
    $(this).addClass('selected');
    $('.checkbox',parent).attr('checked', false);
    $("#overnightHidden").empty();
    $("#overnightHidden").val("false");
});
$(".rep-daily").click(function(){
    var parent = $(this).parents('.switch');
    $('.rep-weekly',parent).removeClass('selected');
    $(this).addClass('selected');
    $('.checkbox',parent).attr('checked', true);
    $("#reccurType").empty();
    $("#reccurType").val("true");
});
$(".rep-weekly").click(function(){
    var parent = $(this).parents('.switch');
    $('.rep-daily',parent).removeClass('selected');
    $(this).addClass('selected');
    $('.checkbox',parent).attr('checked', false);
    $("#reccurType").empty();
    $("#reccurType").val("false");
});
$(".rep-cycle").click(function(){
    var parent = $(this).parents('.switch');
    $('.rep-endDate',parent).removeClass('selected');
    $(this).addClass('selected');
    $('.checkbox',parent).attr('checked', true);
    $("#reccurWay").empty();
    $("#reccurWay").val("true");
    $("#endDate").hide();
    $("#cycle").show();
});
$(".rep-endDate").click(function(){
    var parent = $(this).parents('.switch');
    $('.rep-cycle',parent).removeClass('selected');
    $(this).addClass('selected');
    $('.checkbox',parent).attr('checked', false);
    $("#reccurWay").empty();
    $("#reccurWay").val("false");
    $("#cycle").hide();
    $("#endDate").show();
});

 })(jQuery);

At this line:

})(jQuery);

I have the error Uncaught TypeError: object is not a function Please help

Upvotes: 0

Views: 802

Answers (1)

Niels
Niels

Reputation: 49959

Just remove this:

 })(jQuery);

to

 });

Because it's not an anonymous function you're calling, but the document ready, which does not need such direct call.

Upvotes: 3

Related Questions