twitter bootstrap modal — how to pass data to callback function

前端 未结 3 1031
忘了有多久
忘了有多久 2021-01-26 05:18

is there a way to pass additional data to bootstrap modal function callback?

for example, lets say my link that causes the modal to open has an extra attribute in it wit

3条回答
  •  不思量自难忘°
    2021-01-26 05:52

    Could this work for you ?

     Edit Task List
    
    var $editTaskList = $('#editTaskList');
    
    $('body').on('click.modal.data-api', '[data-toggle="datamodal"]', function (e) {
        var $this = $(this);
        $editTaskList.data('anyAttr',$this.data('anyAttr'));
        $editTaskList.modal('show');
        e.preventDefault();
    })
    
    $editTaskList.on('show', function () {
        var myData = $editTaskList.data('anyAttr');
    });
    

提交回复
热议问题