我有一个带有javascript函数的rails应用程序页面,如下所示。
我想将确认对话框更改为引导确认。我不确定我是否这样做我会调用load_data()函数来获取数据。
任何帮助都将受到高度赞赏。
jQuery(function(){
var form_changed = false;
$(document).on("click", "#comments span", function() {
var version_id = $(this).attr("data-id");
var data_field_id = $(this).attr("data-field-id");
if (form_changed && !confirm("You have made changes to the form. Are you sure you want to leave without saving?"))
return false;
load_data();
form_changed = false;
function load_data(){
$.ajax({
type:"GET",
url:"/products/"+product_id,
dataType:"json",
success:function(result){
$('#' + data_field_id).val(result.value);
}
});
}
});