I'm new to jQuery and java and I'm really trying to get my head round creating multiple instances of a dialog box. I'm using this in the head:
<script src="external/jquery/jquery.js"></script>
<script src="jquery-ui.js"></script>
If I just have 1 button and and dialog box it works. But when I add another it stops working. I'm sure it will be quite easy to fix I'm just struggling.
<h2>subjects</h2>
<button id="opener">maths</button>
<div id="dialog" title="Dialog Title">maths is an important subject.</div> <br>
<button id="opener">english</button>
<div id="dialog" title="Dialog Title">this is also very important</div> <br>
<script>
$( "#dialog" ).dialog({ autoOpen: false });
$( "#opener" ).click(function() {
$( "#dialog" ).dialog( "open" );
});
</script>
http://jsfiddle.net/y7952dmf/
HTML:
JQ:
IDs are used to tell it what object you are working with. You need to give them separate names to have it know what to work with.
This should be what you are looking for.