简体   繁体   English

回发时停止JQuery滑入

[英]Stopping JQuery Slide-in on postback

I am working on an asp.net webpage with a jquery slider to slide a div in and out. 我正在使用一个jquery滑块在asp.net网页上滑动div进出。 The div includes three asp dropdown lists, with values initialised by the page load routine in the server side VB. div包括三个asp下拉列表,其值由服务器端VB中的页面加载例程初始化。 On the first drop down I want to have autopostback so depending on the item selected, the second drop down list is rebound. 在第一个下拉列表中,我希望具有自动回传功能,因此根据所选项目,第二个下拉列表是反弹。

Unfortunately, when autopostback is triggered, the whole div is sliding back into its starting position, although on sliding the div back onto the screen, I can see that the autopostback routine worked and rebound the second drop down. 不幸的是,当触发自动回发时,整个div都滑回其初始位置,尽管在将div滑回屏幕上时,我可以看到自动回发例程起作用并在第二个下拉菜单中反弹。

Is there anyway to stop the div sliding back to its starting position unless the handle button is clicked? 无论如何, 除非单击手柄按钮, 否则是否可以使div滑回其初始位置?

I am using jquery.tabSlideOut.v1.3.js, but i have copied and pasted below if its of any use: 我正在使用jquery.tabSlideOut.v1.3.js,但如果有任何用途,请复制并粘贴以下内容:

(function($){
$.fn.tabSlideOut = function(callerSettings) {
    var settings = $.extend({
        tabHandle: '.handle',
        speed: 300, 
        action: 'click',
        tabLocation: 'right',
       topPos: '1px',
       leftPos: '20px',
        fixedPosition: false,
        positioning: 'absolute',
        pathToTabImage: null,
        imageHeight: null,
        imageWidth: null,
        onLoadSlideOut: true                       
    }, callerSettings||{});

    settings.tabHandle = $(settings.tabHandle);
    var obj = this;
    if (settings.fixedPosition === true) {
        settings.positioning = 'fixed';
    } else {
        settings.positioning = 'absolute';
    }

    //ie6 doesn't do well with the fixed option
    if (document.all && !window.opera && !window.XMLHttpRequest) {
        settings.positioning = 'absolute';
    }

    //set initial tabHandle css

    if (settings.pathToTabImage != null) {
        settings.tabHandle.css({
        'background' : 'url('+settings.pathToTabImage+') no-repeat',
        'width' : settings.imageWidth,
        'height': settings.imageHeight
        });
    }

    settings.tabHandle.css({ 
        'display': 'block',
        'textIndent' : '-99999px',
        'outline' : 'none',
        'position' : 'absolute'
    });

    obj.css({
        'line-height' : '1',
        'position' : settings.positioning
    });

    var properties = {
                containerWidth: parseInt(obj.outerWidth(), 10) + 'px',
                containerHeight: parseInt(obj.outerHeight(), 10) + 'px',
                tabWidth: parseInt(settings.tabHandle.outerWidth(), 10) + 'px',
                tabHeight: parseInt(settings.tabHandle.outerHeight(), 10) + 'px'
            };

    //set calculated css
    if(settings.tabLocation === 'top' || settings.tabLocation === 'bottom') {
        obj.css({'left' : settings.leftPos});
        settings.tabHandle.css({'right' : 0});
    }

    if(settings.tabLocation === 'top') {
        obj.css({'top' : '-' + properties.containerHeight});
        settings.tabHandle.css({'bottom' : '-' + properties.tabHeight});
    }

    if(settings.tabLocation === 'bottom') {
        obj.css({'bottom' : '-' + properties.containerHeight, 'position' : 'fixed'});
        settings.tabHandle.css({'top' : '-' + properties.tabHeight});

    }

    if(settings.tabLocation === 'left' || settings.tabLocation === 'right') {
        obj.css({
            'height' : properties.containerHeight,
            'top' : settings.topPos
        });

        settings.tabHandle.css({'top' : 0});
    }

    if(settings.tabLocation === 'left') {
        obj.css({ 'left': '-' + properties.containerWidth});
        settings.tabHandle.css({'right' : '-' + properties.tabWidth});
    }

    if(settings.tabLocation === 'right') {
        obj.css({ 'right': '-' + properties.containerWidth});
        settings.tabHandle.css({'left' : '-' + properties.tabWidth});

        $('html').css('overflow-x', 'hidden');
    }

    //functions for animation events

    settings.tabHandle.click(function(event){
        event.preventDefault();
    });

    var slideIn = function() {

        if (settings.tabLocation === 'top') {
            obj.animate({top:'-' + properties.containerHeight}, settings.speed).removeClass('open');
        } else if (settings.tabLocation === 'left') {
            obj.animate({left: '-' + properties.containerWidth}, settings.speed).removeClass('open');
        } else if (settings.tabLocation === 'right') {
            obj.animate({right: '-' + properties.containerWidth}, settings.speed).removeClass('open');
        } else if (settings.tabLocation === 'bottom') {
            obj.animate({bottom: '-' + properties.containerHeight}, settings.speed).removeClass('open');
        }    

    };

    var slideOut = function() {

        if (settings.tabLocation == 'top') {
            obj.animate({top:'-3px'},  settings.speed).addClass('open');
        } else if (settings.tabLocation == 'left') {
            obj.animate({left:'-3px'},  settings.speed).addClass('open');
        } else if (settings.tabLocation == 'right') {
            obj.animate({right:'-3px'},  settings.speed).addClass('open');
        } else if (settings.tabLocation == 'bottom') {
            obj.animate({bottom:'-3px'},  settings.speed).addClass('open');
        }
    };

   var clickAction = function(){
        settings.tabHandle.click(function(event){
            if (obj.hasClass('open')) {
                slideIn();
            } else {
                slideOut();
            }
        });

    };

    if (settings.action === 'click') {
        clickAction();
    }

    if (settings.action === 'hover') {
        hoverAction();
    }

    if (settings.onLoadSlideOut) {
        slideOutOnLoad();
    };

};
})(jQuery);

The drop downs in the div I am sliding are... 我滑动的div中的下拉菜单是...

<asp:DropDownList ID="ddContinent" AutoPostBack="true"   runat="server">
                <asp:ListItem>ALL</asp:ListItem>
                <asp:ListItem>Africa</asp:ListItem>
                <asp:ListItem>Americas</asp:ListItem>
                <asp:ListItem>Asia</asp:ListItem>
                <asp:ListItem>Europe</asp:ListItem>
</asp:DropDownList>

<asp:DropDownList ID="ddCountry"   runat="server">
</asp:DropDownList>

ddCountry is initialised on pageload and I am rebinding depending on the continent selected in the first drop down using a ddContinent.SelectedIndexChanged type function on the server side VB. ddCountry在页面加载时初始化,我根据服务器端VB上的ddContinent.SelectedIndexChanged类型函数根据第一个下拉列表中选择的洲重新绑定。 To clarify - this bit is working. 要澄清-此位正在工作。 I am trying to work out how to stop the DIV sliding back out of view when the auto post back is triggered 我正在尝试找出如何在触发自动回发时阻止DIV滑回视图

Any ideas? 有任何想法吗?

EDIT: I haven't found a definite answer yet, but rummaging around the web, one option may be to use a button click to activate the slider instead of the "a" link. 编辑:我还没有找到一个明确的答案,但是在网上翻遍,一种选择可能是使用按钮单击来激活滑块,而不是“ a”链接。 then maybe use cookie or a label to store if the div should be visible or not. 那么也许可以使用cookie或标签来存储div是否可见。 the value could be updated by the button click alone and would be a condition of the slider sliding. 该值可以通过单独单击按钮来更新,并且可能是滑块滑动的条件。

I use C# instead of VB.Net but this should help : 我使用C#代替VB.Net,但这应该有所帮助:

.ASPX .ASPX

<asp:DropDownList ID="ddContinent" AutoPostBack="true" OnSelectedIndexChanged ="UpdateCountry" runat="server">

Code-behind : 后台代码:

   Private Sub UpdateCountry(ByVal sender As Object, _
        ByVal e As System.EventArgs) 
   // update countries
  End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM