如何在Broadleaf管理面板中删除任何内容之前启用提示?

时间:2017-10-10 13:44:47

标签: javascript jquery css html5 broadleaf-commerce

在删除Broadleaf(4.0)管理面板中的任何内容(例如产品)之前,是否有开箱即用的方法来设置提示窗口或类似内容?现在,当我点击“删除”按钮时,它只是删除它们而不先询问。我找到了一个javascript可能会这样做但在我尝试之前我想确定在Broadleaf中是否没有这样的选项?我找到的javascript是一个链接,它是这样的:

$(function() {
    $('.confirm').click(function(e) {
        e.preventDefault();
        if (window.confirm("Are you sure you want to delete?")) {
            location.href = this.href;
        }
    });
});

的javascript:

function userSave(){
var userId=$("#userId").val();
var companyId=$("#companyId").val();
debugger;
Liferay.Service(
          '/MyLibrary_ServiceBuilder-portlet.searchhistory/display-saved',
          {
            userId: userId,
            companyId: companyId
          },
          function(obj) {
            console.log(obj);
            html='';
            var i;
            for(i =0;i<obj.length;i++){

                html+="<li id='"+obj[i].searchHistoryId+"' name='keywordSearch'>"+obj[i].keywordSearch+"</li>";
                html+="<li>"+obj[i].searchTime+"</li>";
                html+="<input type='hidden' id='saved' name='saved' value='"+obj[i].saved+"'>";
                debugger;
                html+="<input type='button' name='updateSearch' onclick='statusUpdate("+obj[i].toString()+");' value='delete save'>";
            }

            $("#userSave").append(html);
          }
        );
}

function statusUpdate(obj){
console.log(obj);
debugger;
obj={
        'userId':userId,
        'companyId':companyId,
        'groupId':groupId,
        'keywordSearch':'"'+keywordSearch+'"',
        'updatedOn':updatedOn,
        'saved':saved,
        'query':'"'+query+'"'
}
Liferay.Service(
          '/MyLibrary_ServiceBuilder-portlet.searchhistory/update-to-search-history',
          {
            strSearchHistory: obj
          },
          function(obj) {
            console.log(obj);
          }
        );
}

1 个答案:

答案 0 :(得分:1)

最简单的选择就是在删除此代码之前将其删除:

confirm("Are you sure you want to delete this?");