Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6970985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:46:48+00:00 2026-05-27T16:46:48+00:00

I have the following code in main.js : (function($) { // Code goes here

  • 0

I have the following code in main.js:

(function($) {
    // Code goes here
    $.fn.switcher=function(opts)
    {
        var defaults={
            btn:'.info_btn', //Класс кнопки
            block:'.details_info', //Класс блока, который нужно скрыть
            hideifout:false, //Если true то скроект блок когда мышь его покент
            classActive:'open' //Класс который ставится активной кнопке
            //classNotActive:'close'
        };
        var options=$.extend(defaults, opts);
        this.each(
            function(){
                var $this=$(this);
                var btn=$this.find(options.btn);
                var block=$this.find(options.block);
                var plaing=false;
                var click=function(e){
                    if (e.type=='mouseleave')
                    {
                        e.stopPropagation();
                    }
                    if (plaing) return;
                    plaing=true;
                    if (block.is(':visible'))
                    {
                        block.hide('blind',function(){
                            btn.removeClass(options.classActive);
                            btn.css('z-index',0);
                            plaing=false;
                        });
                    } else {
                        btn.addClass(options.classActive);
                        btn.css('z-index',2);
                        block.show('blind',function(){

                            plaing=false;
                        });
                    }
                }

                btn.click(click);
                if (options.hideifout){
                    block.mouseleave(click);
                }

            }
        );
    }
})(jQuery);

And js code in my aspx file:

<script type="text/javascript">
    $(document).ready(function () {
        $('#listInfoBlock').load('/cinema/filmlist'); // load films by default

        $(".title").click(function (e) {
            e.preventDefault();
            loadFilmList($(this));
        });

        $("#buttonFindFilmByName").click(function (e) {
            e.preventDefault();
            loadFilmList($(this));
        });

        // load films by criteria
        function loadFilmList(id) {
                $('#listInfoBlock').load('/cinema/filmlist?id=' + $(id).attr("id"));
                $(".tabs").find("a").removeClass("active");
                $(id).parent().addClass("active");

            };
    });
</script>

The function loadFilmList fills listInfoBlock.
The problem in that function in main.js executes first and there are no div called .details_info (it will be there when loadFilmList is executed)

How can I solve this problem?
Thanks.

SOLUTION:

I rewrite like that:

function loadFilmList(id) {
            $('#listInfoBlock').load('/cinema/filmlist?id=' + $(id).attr("id"), function () {
                $('.infoBlock').switcher();
                $('div.widgets').switcher(
                    {
                        btn: '.expand',
                        block: '.voice_block',
                        hideifout: true
                        // classActive:'expand'
                    });
            });
            if (id !== undefined) {
                $(".tabs").find("a").removeClass("active");
                $(id).parent().addClass("active");
            }            
        };

now it’s work.
Thanks Nate.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:46:49+00:00Added an answer on May 27, 2026 at 4:46 pm

    The problem is that you’re declaring $.fn.switcher but aren’t ever calling it anywhere. I think you need to call it in two places, in a callback function on both of your .load() AJAX calls.

    $('#listInfoBlock').load('/cinema/filmlist', function() { $.fn.switcher({ }); });
    

    and

    $('#listInfoBlock').load('/cinema/filmlist?id=' + $(id).attr("id"), function() { $.fn.switcher({ }); });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: $('#main-nav a').mouseover(function() { var name = $(this).attr(rel); $(#subnav ul.
I have the following code: $(.main).click(function() { $(this).toggleClass(classA).toggleClass(classB); $(.secondary).toggleClass(classC).toggleClass(classD); )); $(.secondary).click(function() { $(.secondary).toggleClass(classC).toggleClass(classD); ));
I have the following code: main = do putStr Test input : content <-
I have the following code int main() { int a=6; void *p; p=&a; p++;
I have following code public class TEST { public static void main(String arg[]){ try
I have the following code: class Program { static void Main(string[] args) { new
I have the following code: public class Test { public static void Main() {
i have the following code: #include <stdio.h> int main(void) { float a[4] __attribute__((aligned(0x1000))) =
I have the following code: #include <string.h> int main(void) { char *buffer = NULL,
I have following Code Block Which I tried to optimize in the Optimized section

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.