UI Dialog - How to bind to elements after dialog is loaded?
I have a dialog that loads a page int to the dialog likes so(
http://example.nemikor.com/creating-dialogs-on-demand/) but I want to be able to attach to elements in the page once it is loaded into the dialog and call handlers. This seems like an easy one but I can's seem to get the functionality to work.
This is the page that loads into the dialog...
team.php
<!-- product options -->
<div id='league1' class='team-options'>
<div id='team-options'>
<h3>Color Selection</h3>
<div class='option-list'>
<p>Select a color</p>
<ul>
<li><input name='color' value='red' type='radio' /> Red</li>
<li><input name='color' value='yellow' type='radio' /> Yellow</li>
<li><input name='color' value='white' type='radio' /> White</li>
</ul>
</div>
<h3>Size Selection</h3>
<div class='option-list'>
<select name='916ps59_size_options' id='916ps59_size_options'>
<option value='0'>Small</option>
<option value='1'>Medium</option>
<option value='3'>Large</option>
<option value='2'>X-Larger</option>
</select>
</div>
</div>
I would like to have a handler identify what the user selects after they have mad a selection. I have attempted to create a method to set up bindings and attach it to the :open event. However, that event appears to run before the page xhtml has loaded into the DOM.
-
littleleague.js
$(document).ready(function(){
//Popup window
$('.launch').bind('click',function(e){popwindow(e)});
//Modal window
var $loading = $('<img src="loading.gif" alt="loading" class="loading">');
//For each link with class bind load dialog to the click event
$('.league').each(function() {
var $dialog = $('<div></div>')
.append($loading.clone());
var $link = $(this).one('click', function() {
$dialog
.load($link.attr('href') + ' #league-uniform')
.dialog({
title: $link.attr('title'),
width: 686,
height: 448,
modal:true,
open: SetBindings()
});
$link.click(function() {
$dialog.dialog('open');
return false;
});
return false;
});
});
This has got to be a simple. Any one?