Details
Confirming file deletion (or other actions)
By Paul
Jan 12, 2016 pm31 9:55 PM
Sometimes, users act before they think. Those big inviting delete buttons on their file attachments when editing a listing may get clicked without good reason, and then the file is lost. The solution? A confirmation yes/no dialog.
The 9.2.40 Beta 1 release adds a new javascript handler function to help with this, named wsn_makeconfirmdialogajax. It takes two parameters: the first is the name of another javascript function which will be called when the user says 'yes' to the dialog, and the second is the value of a parameter to pass to that function.
You can use this function to make a confirmation dialog for any javascript event. If you'd like to make a confirmation dialog for a simple url redirect event, use the wsn_makeconfirmdialog function instead -- the only parameter you need to pass to that is the destination URL.
For confirming file attachment deletion, we'll just need to go to Admin -> Themes -> Manage Templates -> File Uploader. In that template, replace wsn_deleteattachment({%=file.attachid%}) with wsn_makeconfirmdialogajax('wsn_deleteattachment', '{%=file.attachid%}') and replace wsn_deleteattachment({ATTACHID}) with wsn_makeconfirmdialogajax('wsn_deleteattachment', '{ATTACHID}')
That's all, you're done!
Please note that as of now this solution is only good for English-only websites because the dialog prompt can't be translated without a very awkward workaround. If you need a multilingual solution, please contact WSN support.
By Paul
Jan 12, 2016 pm31 9:55 PM
The 9.2.40 Beta 1 release adds a new javascript handler function to help with this, named wsn_makeconfirmdialogajax. It takes two parameters: the first is the name of another javascript function which will be called when the user says 'yes' to the dialog, and the second is the value of a parameter to pass to that function.
You can use this function to make a confirmation dialog for any javascript event. If you'd like to make a confirmation dialog for a simple url redirect event, use the wsn_makeconfirmdialog function instead -- the only parameter you need to pass to that is the destination URL.
For confirming file attachment deletion, we'll just need to go to Admin -> Themes -> Manage Templates -> File Uploader. In that template, replace wsn_deleteattachment({%=file.attachid%}) with wsn_makeconfirmdialogajax('wsn_deleteattachment', '{%=file.attachid%}') and replace wsn_deleteattachment({ATTACHID}) with wsn_makeconfirmdialogajax('wsn_deleteattachment', '{ATTACHID}')
That's all, you're done!
Please note that as of now this solution is only good for English-only websites because the dialog prompt can't be translated without a very awkward workaround. If you need a multilingual solution, please contact WSN support.
Tags | jqueryui | ||||
Views | 258 views. Averaging 258 views per day. | ||||
Similar Listings |
|
Sorry, you don't have permission to post. Log in, or register if you haven't yet.
Please login or register.