jquery - Javascript events inside bootstrap popup (bootbox) dont work - Stack Overflow

I´m trying create a bootstrap popup with bootbox modal, inside of form has a input text with masked inp

I´m trying create a bootstrap popup with bootbox modal, inside of form has a input text with masked input, but any events inside of popup don´t work.

See here: /

The html:

<p>The mask input below WORKS great</p>
<p>
    <input type="text" class="mask" />
</p>

<a href="#" class="btn btn-inverse" id="asssf">OPEN BOOTBOX</a>

<div id="frm" style="visibility: hidden">
    <div class="form-horizontal">
        <p>The mask input below DON´T WORK. :-(</p>
        <input type="text" class="mask"/>
    </div>
</div>

JavaScript:

 $("#asssf").click(function (e) {
            e.preventDefault();

     bootbox.dialog({
                  message: $("#frm").html(),
                  title: "Custom title",         
                  buttons: {
                    success: {
                      label: "Success!",
                      className: "btn-danger",
                      callback: function() {
                            return;
                      }
                    }
                  }
            });

           $(".mask").mask("999-99-9999",{placeholder:"_"});
});

$(".mask").mask("999-99-9999",{placeholder:"_"});

How to mask works inside of popup?

I´m trying create a bootstrap popup with bootbox modal, inside of form has a input text with masked input, but any events inside of popup don´t work.

See here: http://jsfiddle/ens1z/UK6x5/5/

The html:

<p>The mask input below WORKS great</p>
<p>
    <input type="text" class="mask" />
</p>

<a href="#" class="btn btn-inverse" id="asssf">OPEN BOOTBOX</a>

<div id="frm" style="visibility: hidden">
    <div class="form-horizontal">
        <p>The mask input below DON´T WORK. :-(</p>
        <input type="text" class="mask"/>
    </div>
</div>

JavaScript:

 $("#asssf").click(function (e) {
            e.preventDefault();

     bootbox.dialog({
                  message: $("#frm").html(),
                  title: "Custom title",         
                  buttons: {
                    success: {
                      label: "Success!",
                      className: "btn-danger",
                      callback: function() {
                            return;
                      }
                    }
                  }
            });

           $(".mask").mask("999-99-9999",{placeholder:"_"});
});

$(".mask").mask("999-99-9999",{placeholder:"_"});

How to mask works inside of popup?

Share Improve this question edited Aug 9, 2019 at 16:26 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Dec 11, 2013 at 15:02 Jeferson TenorioJeferson Tenorio 2,1901 gold badge25 silver badges32 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

Try this fiddle :) HERE

The problem is that you loaded the html to bootbox without his events.

i made a function to solve your problem:

function BootboxContent(){
    var content = $("#frm").clone(true);
    $(content).css('visibility','visible');
     content.find('.mask').mask("999-99-9999",{placeholder:"_"});
 return content ;
}

call it on your message as in the fiddle, or without function like this :

 bootbox.dialog({
              message: $("#frm").clone(true).css('visibility','visible').find('.mask').mask("999-99-9999",{placeholder:"_"}),
              title: "Custom title",         
              buttons: {
                success: {
                  label: "Success!",
                  className: "btn-danger",
                  callback: function() {
                        return;
                  }
                }
              }
        });
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745048622a4608248.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信