In this, I try to open a dialog click on the button.
It's working well but I want to reduce this code because it looks like same on click function
$(document).ready(function() {
$("#dialog_form_file").dialog({
modal: true,
autoOpen: false,
title: "Help",
width: 450,
buttons: [{
text: "OK",
click: function() {
$(this).dialog("close");
}
},
{
text: "Cancel",
click: function() {
$(this).dialog("close");
}
}
]
});
$("#dialog_form").dialog({
modal: true,
autoOpen: false,
title: "Help",
width: 450,
buttons: [{
text: "OK",
click: function() {
$(this).dialog("close");
}
},
{
text: "Cancel",
click: function() {
$(this).dialog("close");
}
}
]
});
$("#dialog_help").click(function() {
$("#dialog_form_file").dialog('open');
});
$("#change_button").click(function() {
$("#dialog_form").dialog('open');
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<link href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" rel="stylesheet"/>
<div id="dialog_form_file" style="display: none">
<p>Hello</p>
</div>
<div id="dialog_form" style="display: none">
<p>Hello</p>
</div>
dialog()method has nohtmlparameter? The OPs use ofdialog()is absolutely fine here.