2013-10-11 178 views
0

我用引導的模式,當我點擊添加更改按鈕,沒有任何反應.. :(jQuery提交不起作用?

腳本頭:

<script> 
$("addBtn").click(function() { 
    $("programFormDropDown").submit(function(event) {   
    }); 
}); 
</script> 

我的語氣中體:

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 
      <div class="modal-dialog"> 
       <div class="modal-content"> 
        <div class="modal-header"> 
         <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> 
         <h4 class="modal-title">Confirm your change</h4> 
        </div> 
        <div class="modal-body">Are you sure you need to add these ? 
        </div> 
        <div class="modal-footer"> 
         <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 
         <button id="addBtn" class="btn btn-primary">Add changes</button> 
        </div> 
       </div> 
       <!-- /.modal-content --> 
      </div> 
      <!-- /.modal-dialog --> 
     </div> 

和我的身體在同一個身體

<form id="programFormDropDown" action="../hDashBoard/project"> 

.....

你能給點建議嗎?

+0

您使用的是Mootools嗎? – Sergio

回答

2

你錯過#在兩個選擇的jQuery

試試這個:

$("#addBtn").click(function() { 
    $("#programFormDropDown").submit(function(event) {   
    }); 
}); 

,而不是這樣的:

$("addBtn").click(function() { 
    $("programFormDropDown").submit(function(event) {   
    }); 
}); 
+1

爲什麼降低?請解釋 –

3

你似乎已經forgoten在你選擇一個#除非您正在使用Mootools,它獲取ID爲$('id')請試試這個:

$("#addBtn").click(function() { 
^
    $("#programFormDropDown").submit(function(event) { 
    ^   
    }); 
}); 
0

看起來你是不是在找AJAX提交,在這種情況下,改變按鈕類型,如果你想使用腳本

/add script in dom ready handler 
jQuery(function() { 
    //use id selectors - # in front of id 
    $("#addBtn").click(function() { 
     //call the dom elements submit method 
     $("#programFormDropDown")[0].submit(); 
    }); 
}) 
2

你似乎遞交像

<button id="addBtn" class="btn btn-primary" type="submit">Add changes</button> 

缺少選擇器中的'#'引用。

<script> 
$("#addBtn").click(function() { 
    $("#programFormDropDown").submit(function(event) {   
    }); 
}); 
</script>