I have a dialog box which opens when I double click on the draggable element. It's purpose is to append an IP address underneath the image:
It works fine but only after I close the dialog box and open it again then click on the Submit button.
Here's my codes:
HTML
<div id="configbox" title="IPv6 Configuration" style="font-size:15px;">
<form>
<b>DHCP</b> <input type="radio" name="option" value="DHCP"/>
<b>Auto Config</b> <input type="radio" name="option" value="auto"/>
<b>Static</b> <input type="radio" name="option" value="static"/> <br/><br/>
<table>
<tr>
<td>
<b>IPv6 Address:</b>
</td>
<td>
<input type="text" id="address" size="25"/> / <input type="text" id="subnet" size="3"/>
</td>
</tr>
<tr>
<td>
<b>Link Local Address:</b>
</td>
<td>
<input type="text" id="local" size="35"/>
</td>
</tr>
<tr>
<td>
<b>IPv6 Gateway:</b>
</td>
<td>
<input type="text" id="gateway" size="35"/>
</td>
</tr>
<tr>
<td>
<b>IPv6 DNS Server:</b>
</td>
<td>
<input type="text" id="dns" size="35"/>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
</table>
</form>
<center>
<button id="submit"
style="background-color:#B4BA22; border-radius:3px; font-size:17px; font-weight:bold; cursor:pointer;">Submit
</button>
<button id="cancel"
style="border-radius:3px; font-size:17px; font-weight:bold; cursor:pointer;"> Cancel
</button>
</center>
</div>
JQuery
$(document).click(function (e) {
// matches all children of droppable, change selector as needed
currentDragImg = $(e.target).closest(".drag");
if ($(e.target).closest(".drag").length > 0) {
$(e.target).closest(".drag").find(".ui-resizable-handle").show();
}
else {
$("#droppable").find(".ui-resizable-handle").hide();
$("#tools").hide();
}
$('.drag').dblclick(function () { //the dialog box to enter the IP address opens on double click
$('#configbox').dialog('open');
return false;
});
});
/*The submit button*/
$(function () {
$("#submit").click(function () {
enter = $("#address").val();
$("<div>"+enter+"</div>").appendTo(currentDragImg);
});
});
Any idea why this is happening? Any input will be appreciated. Thanks.
