Ad

Call Function Is Not A Function

- 1 answer

$(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 ?

Ad

Answer

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);
Ad
source: stackoverflow.com
Ad