Getting data from the dialog
Because the widget is a part of the underlying page, passing data to and from it is simple. The dialog can be treated as any other standard element on the page. Let's look at a basic example.
We looked at an example earlier in the chapter, which added some <button>
elements to the dialog. The callback functions in that example didn't do anything, but the following example gives us the opportunity to use them. Replace the existing dialog markup in dialog8.html
with the following:
<div id="myDialog" title="Best Widget Library"> <p>Is jQuery UI the greatest JavaScript widget library?</p> <label for="yes">Yes!</label> <input type="radio" id="yes" value="yes" name="question" checked="checked"><br> <label for="no">No!</label> <input type="radio" id="no" value="no" name="question"> </div>
Now change the final <script>
element as follows:
<script> $(document).ready(function($){...