小编ric*_*chj的帖子

jQuery:contains()适用于Firefox但不适用于Chrome/Safari

我有一个ajax函数,它根据下拉列表中的选定值获取一些值.我正在尝试根据子字符串启用/禁用某些字段.我发现'contains'可以在firefox中运行,但在chrome和safari中测试告诉我对象'没有方法包含'

if ($d.attr("embed").contains('$var_2$')) { 
    //do something
} else {
    // do something else
}
Run Code Online (Sandbox Code Playgroud)

是否有包含的替代品可以在所有浏览器中使用?

jquery contains

10
推荐指数
1
解决办法
8758
查看次数

jQuery Bootstrap多个模态,如何隐藏active/top模态

我有一个模态形式,有时需要打开第二个模态来设置或显示一些数据.我能够启动第一个和第二个模态OK,但是当我关闭'top'模态时,两个模态都被隐藏了.是否有可能一次隐藏一个模态?

显示模态一:

$('#content').on('click', "a#AddItemModal", function () {
    var id = $(this).attr('value');

    var val = '/AddItems/id:' + id;

    $('#addItemBody').load(val);
    $('#addItemModal').modal({});

});
Run Code Online (Sandbox Code Playgroud)

模态一:

<div class="modal fade hide" id="addItemModal" tabindex="-1" role="dialog">
    <div class="modal-body">
        <p id="addItemBody"></p>
    </div>
    <div class="modal-footer">
        <a href="#" class="btn"  data-dismiss="modal" id="good">Close</a>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

显示模态二:

$('#test_embed').click(function () {
        var val = $('#formEmbed').val();
        $('#myModalLabel').html('Embed Preview');
        $('#embedBody').html(val);
        $('#embedModal').modal({});
    });
Run Code Online (Sandbox Code Playgroud)

模式二:

<div class="modal fade hide" id="embedModal" tabindex="-1" role="dialog">
    <div class="modal-header">
        <h3 id="myModalLabel">Embed Preview</h3>
    </div>
    <div class="modal-body">
        <p id="embedBody"></p>
    </div>
    <div class="modal-footer">
        <button class="btn" data-dismiss="modal">Close</button>
    </div> …
Run Code Online (Sandbox Code Playgroud)

jquery modal-dialog twitter-bootstrap

8
推荐指数
2
解决办法
3万
查看次数

Ajax刷新后如何绑定jQuery Datepicker?

我有一个非常适合我的 jQuery 日期选择器,除了当我通过 ajax 刷新内容时,我丢失了日期选择器。据我所知,我应该使用 jQueryon()将其绑定到输入,但我似乎无法找到将其绑定到的正确事件。

第一次有效,但在后续刷新时无效:

$("[id^=startPicker]").datetimepicker({
        showOn: "button",
        buttonImage: "/img/calendar_icon.png",
        buttonImageOnly: true,
        dateFormat: 'mm/dd/yy',
        timeFormat: 'hh:mm tt',
        stepMinute: 1,
        onClose: function (dateText, inst) {

            var selectedDate = $(this).datepicker("getDate"); //Date object

            $.ajax({
                url: "/url",
                dataType: "json",
                method: 'post',
                data: {
                    value: selectedDate.toDateString() + ' ' + selectedDate.toTimeString()
                },
                beforeSend: function () {
                    $("#loading").fadeIn();
                },
                success: function (data, textStatus) {
                    $("#content").html(data);
                },
                complete: function () {
                    $("#loading").fadeOut();
                }
            });
        }
    });
Run Code Online (Sandbox Code Playgroud)

第一次或后续刷新时不绑定:

$('#content').on('ready', "[id^=startPicker]", function () {
        $(this).datetimepicker({ …
Run Code Online (Sandbox Code Playgroud)

ajax jquery datepicker jquery-events

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