jQuery不会再次滑出 [英] JQuery Won't Slide Out a Second Time

查看:112
本文介绍了jQuery不会再次滑出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为我上一个问题的跟进,当前我的实时网站上有以下代码:

As a follow up from my previous question, I currently have this code on my live site:

http://jsfiddle.net/3veht/6/

与实时站点完全相同.但是由于某种原因,当我打开一个抽屉时,它只能工作一次(打开和关闭),如果我再试一次,它将无法工作.控制台中完全没有错误.

It is the exact same thing as on the live site. But for some reason, when I go to open one of the drawers, it will work a single time (open and close) then if I try again, it will not work. No errors in console at all.

如果我重新加载页面,它将再次运行一次,然后不再打开.

If I reload the page, it will work that single time again, then not open again.

为了帮助,它正在返回数据发送部分,因为它正在返回数据,它不会滑下抽屉.

To help, it is getting to the data sending part because it is returning data, it just won't slide down the drawer.

也许有更好的方法来处理独特商品的滑倒吗?这是上面小提琴的预览:

Maybe there is a better way to handle the slidedown for unique items? Here's a preview from the above fiddle:

 $('.patient').click(function(){
                 var pat = $(this);
                 if ($('#drawer').is(':visible'))
                     $('#drawer').slideUp("slow", function () {

                        $('#drawer').slideDown('slow')
                        $('#drawer').load('/echo/js?js=' + pat.data('patientid'));       
                     });
                 else   
                 {
                     $('#drawer').slideDown('slow')
                     $('#drawer').load('/echo/js?js=' + pat.data('patientid'));
                 }
             });

默认情况下,在CSS中将抽屉设置为显示:无

Drawer by default is set in css to display:none

我还注意到,当抽屉关闭时,它会设置样式为display:block.

I also notice when the drawer closes it sets a style to display:block to the drawer.

也许有帮助.

另外,查看源代码,Jquery认为它正在显示抽屉.动画显然在源中移动,但屏幕上什么都没有.

Also, looking at the source, Jquery thinks it is showing the drawer. The animation is visibly moving in the source but nothing on the screen.

推荐答案

尝试一下

     $(".patient").click(function(){
             var pat = $(this);
             if ($("#drawer").is(":visible")) {
                 $("#drawer").slideUp("slow");
                    $("#drawer").load("/echo/js?js=" + pat.data("patientid"));     
            } else  {
                 $('#drawer').slideDown("slow");
                 $('#drawer').attr("style", "display:block");
                 $("#drawer").load("/echo/js?js=" + pat.data("patientid"));
             }
      });

工作示例 http://jsfiddle.net/3veht/6/

这篇关于jQuery不会再次滑出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆