相关疑难解决方法(0)

jQuery.extend和jQuery.fn.extend之间的区别?

我试图理解jquery插件语法,因为我想将两个插件合并为一个.也需要能够停止de间隔或运行多次的闪光灯.

无论如何,这个语法是一样的

jQuery.fn.extend({
    everyTime: function(interval, label, fn, times) {
        return this.each(function() {
            jQuery.timer.add(this, interval, label, fn, times);
        });
    },
    oneTime: function(interval, label, fn) {
        return this.each(function() {
            jQuery.timer.add(this, interval, label, fn, 1);
        });
    },
Run Code Online (Sandbox Code Playgroud)

这个

$.fn.blink = function(options)
    {
Run Code Online (Sandbox Code Playgroud)

因为它看起来像第一个(没有=)是一次设置多个方法的方法.这是正确的吗?当我在这里时,将元素和一些逻辑添加到jquery对象的原因是什么?

jQuery.extend({
    timer: {
        global: [],
        guid: 1,
        dataKey: "jQuery.timer",
Run Code Online (Sandbox Code Playgroud)

(这是来自计时器插件)

syntax jquery plugins extend

82
推荐指数
5
解决办法
6万
查看次数

从另一个模态打开一个模态并关闭第一个(启动)模态

我正在使用Bootstrap Modal Window插件,它的工作正常,但我想打开另一个模型窗口,当我点击下一个并关闭第一个.我该怎么做?

$('[data-toggle="modal"]').click(function(e) 
    {
        e.preventDefault();
        var url = $(this).attr('href');
        if (url.indexOf('#') == 0)
        {
            $(url).modal('open');
        } 
        else 
        {
            $.get(url, function(data) 
            {
                $(data).modal();
            }).success(function() { $('input:text:visible:first').focus(); });
        }
    });

<a href="next.html" data-toggle="modal">Add Record</a>
Run Code Online (Sandbox Code Playgroud)

next.html文件代码

<div class="modal fade" id="compose-modal" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">First Window</h4>
            </div>
            <form action="#" method="post">

                <div class="modal-footer clearfix">
                    <button type="button" data-dismiss="modal">Discard</button>

                    <button type="submit">Submit</button>
                     <a href="next2.html" data-toggle="modal" >Next</a>
                </div>
            </form>
        </div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

jquery modal-window twitter-bootstrap bootstrap-modal

13
推荐指数
2
解决办法
5万
查看次数

使用另一个模态的模态导致在身体上滚动

https://jsfiddle.net/e6x4hq9h/

打开第一个模态.它打开很好.删除背景滚动条.

从该模态中打开模态.它会导致滚动转到背景.

我搜索了其他解决方案,似乎没有人解决这个问题.我尝试了这个页面上的所有内容:Bootstrap模式:关闭当前,打开新的等等.

使用Javascript:

// Only one of these modals should show at a time.
$('#myModal2').on('show.bs.modal', function (e) {
    $('#myModal').modal('hide');
})
.on('hide.bs.modal', function (e) {
    $('#myModal').modal('show');
});
Run Code Online (Sandbox Code Playgroud)

更新:第一个和第二个模式也必须允许滚动,如在这个小提琴中可以看到:https://jsfiddle.net/e6x4hq9h/21/

css jquery twitter-bootstrap twitter-bootstrap-3

5
推荐指数
1
解决办法
398
查看次数

如何从引导中重用模式HTML?

我有一些包含不同内容的不同模式对话框。基本上,单击button1显示模式对话框1 ...单击button2显示模式对话框2,依此类推。

如何在JavaScript或其他可重用容器中重用该html代码并将数据传递给一个可重用模态?

button1单击的基本代码和modalDialog1的支持代码:

按钮代码(用于单击以显示模式)

<a href="#myModal" role="button" class="btn" data-toggle="modal">Launch demo modal</a>
Run Code Online (Sandbox Code Playgroud)

用于显示模式的HTML ...如何在JavaScript函数或其他方式中重用此代码,并为模式标题和classIDThatContainstheContentsforModal传递一些变量,以便模式可重复使用?

不知道这是否可以纳入JavaScript或其他方法中。

<div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="myModalLabel">Modal Header</h3>
  </div>
  <div class="modal-body">
    <div id="container" class="classIDThatContainstheContentsforModal">
  </div>
  <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
    <button class="btn btn-primary">Save changes</button>
  </div>
</div> 
Run Code Online (Sandbox Code Playgroud)

twitter-bootstrap

3
推荐指数
1
解决办法
5185
查看次数