Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Named $(window) selector wont trigger functions

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #167104
    Anonymous
    Inactive

    Once i named $(window) to $(window.named) The functions within wont trigger on resize. I’m not entirely sure why. Can anyone explain?

    $(window.named).resize(function() {
    
    `sidebarTest();
    
    $("#focus").fadeOut();
    
    SidebarResonsive();
    `
    
    });
    
    #167105
    __
    Participant

    What is window.named?

    It would be helpful if you provided a live example (e.g., on codepen) and described:

    • what you want to accomplish
    • how you tried to do it
    • what you expected to happen
    • what actually happened
    #167106
    Anonymous
    Inactive

    My goal is to unbind the resize event for a specific $(window).resize and not the other ones.
    if the if statement is true, i want to unbind the window resize but in order to unbind that one specifically i need to name it, so for example $(window.thisOne).resize() will unbind and the functions within will not trigger only if the if statement is true. But and the if statement is false, the resize() event will not be unbinded and the functions within should be triggered. The problem is not the if statement because i removed it entirely and the functions within $(window.thisOne).resize() should be triggered but they arent once i named it. When i remove thisOne it works fine.

    $(window.thisOne).resize(function() {
    
            responsiveSidebar();
    
            $("#shadow").fadeOut();
    
            resizeBar();
    
    });
    
     if ( $("link").attr("href") == "css/stylesheet-1.css" ) {
    
            hideBar(); // Hide the sidebar initially 
    
            $("thisOne").unbind("resize");
    
     }
    
    #167107
    __
    Participant

    Do the origin and protocols of your main and child windows match?

    #167109
    Anonymous
    Inactive

    Let me restate my question because it all comes down to a simple goal.

    How can i disable a specific $(window).resize() function and not the others?

    if i do this
    $(window).unbind(“resize”);

    it unbinds all of the $(window).resize.

    I would only want to unbind a specific $(window).resize() function and not others that contain different code within.

    #167110
    Anonymous
    Inactive

    Nevermind. I got it working.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.