将参数发送到bootstrap模式

时间:2017-10-18 13:04:33

标签: php jquery twitter-bootstrap modal-dialog

我有许多链接可以打开bootstrap模式弹出窗口:

<a href="itinPage-secManage.view.php" data-act="edit" data-itinID="5" data-secID="15" data-toggle="modal" data-target="#manageSec-model">Edit 15</a>

<a href="itinPage-secManage.view.php" data-act="edit" data-itinID="5" data-secID="32" data-toggle="modal" data-target="#manageSec-model">Edit 32</a>

问题 - 当模态打开它应该得到链接参数:

数据幕=&#34;编辑&#34;数据itinID =&#34; 5&#34;数据secID =&#34; 15&#34;

嗯,它没有发生......

链接页面中的脚本是:

<script>
    // send data to modal file
    $('#manageSec-model').on('show.bs.modal', function (e) {
        var button = $(e.relatedTarget);

        var act = button.data('act');
        var itinID = button.data('itinid');
        var secID = button.data('secid');
        var date = button.data('date');

        var $modal = $(this);
        var info = 'act=' + act + "&itinID=" + itinID + "&secID=" + secID + "&date=" + date;         
    //  alert(info);

        $.ajax({
            cache: false,
            type: 'GET',
            url: 'itinPage-secManage.view.php',
            data: info,
            success: function(data) {
                $modal.find('.modal-body').html(data);
                setTimeout(function(){ //added this line.
                   setImageUploader()
                })                  
            }
        });     
    }); 

</script>

模态:

echo "itinID: ".$_GET['itinID']." secID: ".$_GET['secID'];

模态结果:

itinID:secID:

itinID:5 secID:15

两行(不知道为什么......)

2 个答案:

答案 0 :(得分:0)

要使其正常工作,您必须在点击锚标记时调用ajax并将值传递给ajax,您可以在点击锚标记时执行以下操作

$(this).attr("id"); 

$(this).attr("data-secID");//haven't tried this 2nd one

然后使用JavaScript或jQuery启动modal

$("#someId").modal();

答案 1 :(得分:0)

尝试更改

var button = $(e.relatedTarget);

var button = $(e.target);