I want to created a JQuery dialog with image button. I tried replacing the button with my image, but it's not working as expected. I also tried to prepend my image src to the button, no luck either. so i would like to know if it is possible to create image button in JQuery dialog?
I'll assume that you're already able to get what you want on a regular button, not in a dialog box.
You don't have to use the buttons
option to put buttons in a dialog box. You can just do it in the normal fashion:
<div id="dialogWithButtons">
<button id="saveButton">Save</button>
<button id="cancelButton">Cancel</button>
</div>
And then in your script:
$('#dialogWithButtons').dialog();
$('#saveButton').on('click', function(e, ui) {
//do whatever
});
And so on. I'll leave you to work out the details specific to your situation.
One thing, though: you need to make sure that your jQuery selector uniquely references your buttons. This came up in my case with cancel buttons, because I had a .cancelButton
class that I used for my click event handler for a number of pages (since there was only one per page). If you do this, clicking the cancel button will run (or at least in my case, ran) the handler as if you clicked the cancel button on the main page.