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?






Please show code so we can assist you

– Li357
Sep 2 '16 at 21:13






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

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)