Image button in jQuery dialog
Image button in jQuery dialog
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?
style your button such that it does not have border,and use your image as background
– Ji_in_coding
Sep 2 '16 at 21:16
$dialogContent.dialog( buttons: save: function () ).show(); this creates the button. I want my image instead of save button.
– Jack philip
Sep 2 '16 at 21:16
1 Answer
1
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:
buttons
<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.
.cancelButton
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy
Please show code so we can assist you
– Li357
Sep 2 '16 at 21:13