javascript - Passing additional (custom) arguments to a bootstrap modal -
i'm using twitter bootstrap modal on page. need pass custom arguments it. how can it? , how access them within modal?
<!-- show modal --> $("#mymodal").modal("show"); <!-- modal --> #mymodal.modal.fade{tabindex: -1, role: :dialog, "aria-labelledby" => "mymodallabel", "aria-hidden" => true} .modal-dialog .modal-content .modal-header %button{type: :button, class: "close", "data-dismiss" => :modal, "aria-hidden" => true} × %h4.modal-title#mymodallabel take address .modal-body modal body .modal-footer %button{type: :button, class: "btn btn-primary"} ok
you seek using data-* attribute , jquery.data() api.
set argument declaratively using data-* attribute in modal tag:
<div class="modal fade" id="mymodal" data-argument="the_argument" ...> ... </div> or set programatically using jquery.data() api:
$('#mymodal').data('argument', the_argument); then, access argument within modal, query using jquery.data() api:
var the_argument = $('#mymodal').data('argument'); jsfiddle example: http://jsfiddle.net/drk6c/
javascript jquery twitter-bootstrap twitter-bootstrap-3
No comments:
Post a Comment