So i am using ajax jquery .load() function to retrieve books using their ISBN the id in a jquery dialog. I am trying to return the value to a input box on the page the dialog is being opened on with no luck. When i click the links, nothing happens. Below is my jquery code.
<script type="text/javascript">
$(document).ready(function(){
// dialog init
$('.choosebookbox').dialog({
autoOpen: false,
resizable: false,
modal: true,
width: 600,
height:600,
title: 'Choose a book',
overlay: { backgroundColor: "#000", opacity: 0.5 }
});
// click event
$('a#booksearch_lnk').click(function(){
$('.choosebookbox').dialog('open').css('display','block');
$('#tab2').load('post/topsellers.php');
$('#tab1').load('post/newbooks.php');
$('a.choosebook').click(function(){
// alert($(this).attr('id'));
$("#isbn").val($(this).attr('id'));
$('.choosebookbox').dialog("close");
});
});
});
</script>
and a sample book link that appears in the modal/dialog…
<a id="0439064864" class="choosebook" href="#">Harry Potter and the Chamber of Secrets (Book 2)</a>
A guess is that your links are loaded with your ajax and so do not belong to the DOM initially. In this case try the live
function.
Did your commented out
alertdisplay anything?