小编Ros*_*oss的帖子

按钮单击不在模态窗口中触发(Bootstrap)

我在模态窗口中有一个按钮:

<button id="submit_btn" class="btn btn-link">Send the invitation</button>
Run Code Online (Sandbox Code Playgroud)

我正在尝试捕获点击:

$('#submit_btn').click(function(event){
    event.preventDefault();
    alert( "GO" ); 
});
Run Code Online (Sandbox Code Playgroud)

我已经读过按钮点击在模态窗口中被吞下,为了防止这种情况,请使用event.preventDefault().但那不起作用.我无法捕获此按钮的click事件.

我还缺少什么?

任何提示都非常感谢!

javascript jquery twitter-bootstrap

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

jQuery Mobile selectmenu焦点和模糊事件不会触发

当表单元素被赋予焦点时,我试图隐藏页脚.我还想在表单元素失去焦点时显示页脚,模糊事件应该处理它.我无法在jQuery Mobile selectmenu表单元素上触发焦点或模糊事件.

这是我的一个表单元素的示例 -

<select id="radiology-study-provider" class="selectList"></select>
Run Code Online (Sandbox Code Playgroud)

这是jQuery代码,它应该隐藏我的页脚在焦点上并在模糊时显示它(它在DOM内部就绪) -

  $('.selectList').change(function(){
      console.log("the change event is firing");
  });
  $('.selectList').focus(function(){
      $('div:jqmData(role="footer")').hide(); // hide the footer
  });
  $('.selectList').blur(function(){
      $('div:jqmData(role="footer")').show(); // show the footer
  });
Run Code Online (Sandbox Code Playgroud)

奇怪的是,更改事件处理程序触发但焦点和模糊不会触发.

我在下面尝试了这个,它不会起作用 -

  $('.selectList').on('focus', function(){
      $('div:jqmData(role="footer")').hide(); // hide the footer
  });
  $('.selectList').on('blur', function(){
      $('div:jqmData(role="footer")').show(); // show the footer
  });
Run Code Online (Sandbox Code Playgroud)

我也试过这个 -

   $('.selectList').bind( "focus", function(event, ui) {
       $('div:jqmData(role="footer")').hide(); // hide the footer
  });
   $('.selectList').bind( "blur", function(event, ui) {
       $('div:jqmData(role="footer")').hide(); // hide the footer
  });
Run Code Online (Sandbox Code Playgroud)

我也尝试了focusin()和focusout()事件,也没有运气.我尝试了几十个选择器(div.ui-select就是其中之一).我不认为这是我正在使用的选择器的问题.

我正在使用jQuery Mobile 1.1.0和jQuery 1.7.1 - …

jquery html5 jquery-mobile cordova

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

异步ajax调用导致KnockOutjs出现问题

我点击了一个按钮,我打电话给:

视图模型:

self.MyArray = ko.observableArray();

self.remove = function(c) {

    ko.utils.arrayForEach(c.sData(), function(ser) {
        if (ser.Check() == true) {
            self.MyArray.push(service);
            count++;
        }
    });

    if (count) {
        $.ajax({
            url: "/api/LoadCustomer/?reason=" + reason,
            cache: false,
            type: 'POST',
            contentType: 'application/json; charset=utf-8',
            data: ko.toJSON(self.MyArray),
            success: function(data) {
                ko.utils.arrayForEach(self.MyArray(), function(removedata) {
                    c.sData.remove(removedata);
                });
            }
        });
        self.MyArray([]);
    }

};
Run Code Online (Sandbox Code Playgroud)

如果我包含async:false在我的ajax调用中我得到一切正常,但如果我没有包括async(它的默认属性是真的)我不知道在我的成功函数ajax调用self.MyArray()仍然,Empty但它不是如此,如果我保持虚假(尴尬) .

有时我担心,如果我async:true在加载到可观察数组(OnLoad)时有一系列的ajax调用,则可能存在轻微错位数据的可能性.

帮帮我理解

asynchronous knockout.js

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