Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call function is not a function

$(function() {
    var previous_page = "<?=$_SESSION["previous_page"]?>";
    if (previous_page == "bar_settings")
        $.club_settings();

    $.club_settings = function() {
        $(".bar_settings").fadeIn(1000);
        $(".bar_photos").hide();
        $(".bar_activities").hide();
        $(".bar_campaigns").hide();
        $(".etkinlik_ekle").hide();
        $(".kampanya_ekle").hide();
    }

})(jQuery);

I got an error that is $.club_settings is not a function. How can i call $.club_settings in a if condition ?

like image 240
Levent Tulun Avatar asked Dec 03 '25 15:12

Levent Tulun


1 Answers

You're defining the function after you call it. Switch around the code like so:

$(function() {
    $.club_settings = function() {
        $(".bar_settings").fadeIn(1000);
        $(".bar_photos").hide();
        $(".bar_activities").hide();
        $(".bar_campaigns").hide();
        $(".etkinlik_ekle").hide();
        $(".kampanya_ekle").hide();
    }

    var previous_page = "<?=$_SESSION["previous_page"]?>";
    if (previous_page == "bar_settings")
        $.club_settings();


})(jQuery);
like image 104
Mike Christensen Avatar answered Dec 06 '25 03:12

Mike Christensen