Jquery-easyui provides simplified encapsulation. This allows us to implement web UI more conveniently.
The confirm method is described as follows in its sample:
$.messager.confirm('My Title', 'Are you confirm this?', function(r){ |
location.href = 'http://www.google.com'; |
For ASP. NET Server-side controls such as linkbutton, we often use
Onclientclick = "Return confirm ('Are you sure you want to delete? ');"
However, if we want to unify the UI, we want to use the confirm of jquery-easyui, but we cannot simply encapsulate
$.messager.confirm('Confirmed', msg, function(r) { |
Then, call:
Onclientclick = "Return confirm ('Are you sure you want to delete? '); "// Note the case sensitivity. This confirm is not another confirm.
We know that what linkbutton actually triggers a business is to use JavaScript Execution in the href attribute.
<A plain ="true" icon="icon-remove" href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$gv$ctl08$LinkButton1','')" onclick="Return confirm ('passed? ');" class="easyui-linkbutton" id="ctl00_ContentPlaceHolder1_gv_ctl08_LinkButton1"> Delete </a>
Therefore, we need to change our thinking and encapsulate it as follows.
// Confirmation box for Asp.net server controls |
|
function Confirm(msg, control) { |
|
$.messager.confirm('Confirmed', msg, function(r) { |
|
eval(control.toString().slice(11));// Cut off javascript: and execute |
Use return confirm ('OK? ', This );