Javascript 从动态创建的按钮打开引导模式?

Javascript 从动态创建的按钮打开引导模式?,javascript,php,jquery,twitter-bootstrap,modal-dialog,Javascript,Php,Jquery,Twitter Bootstrap,Modal Dialog,我正在用PHP构建一个表,使用 echo '<td><button type="button" class="btn btn-default btn-xs" id="edit_'. $info['tablename'] .'">Edit</button></td>'; 我想你只需要以下几点 if (command == "edit" ){ // I want to show this modal but it doesn't work.

我正在用PHP构建一个表,使用

echo '<td><button type="button" class="btn btn-default btn-xs" id="edit_'. $info['tablename'] .'">Edit</button></td>';

我想你只需要以下几点

if (command == "edit" ){
    // I want to show this modal but it doesn't work.
    $('#editModal').modal("show");
}
$(document).on('click',".table .btn",function (e) {
    e.preventDefault();
    var array = String($(this).attr('id')).split('_');
    var id = array[1];
    //Get the command off the button id.
    var command = array[0];

    if (command == "delete" ){
        //do delete stuff
    }   
    if (command == "edit" ){
        // I want to show this modal but it doesn't work.
        $('#editModal').modal({
            "show":"true"   
        });
    }
});
if (command == "edit" ){
    // I want to show this modal but it doesn't work.
    $('#editModal').modal("show");
}