Hi All,
I have a very strange problem with Fancybox.
I can't seem to get the .val() of the inputs which are displayed in Fancybox. They have a value of "". The inputs outside of Fancybox, however work.
My code:
<script type="text/javascript">
$(document).ready(function() {
$('a#inline').fancybox({
'hideOnContentClick': false,
'frameWidth': 500,
'frameHeight': $('#avatars').height(),
'callbackOnShow':
function() {
$('#gallery div img').click(function(){
$('#inline img').attr('src', $(this).attr('class'));
$('input#avatar').attr('value', $(this).attr('class'));
});
$('button').click(function(){
console.log($('input#search_avatar'));
return false;
});
}
});
});
And the HTML:
<fieldset>
<div id="avatars" style="float:left; width:500px; display:none;">
<form method="post" action="">
<fieldset>
<input type="text" name="search_avatar" id="search_avatar" />
<button id="search_avatar_submit">Filter</button>
</fieldset>
<div id="gallery">
<div><img src="2_s.jpg" class="2_s.jpg" /></div>
</div>
</form>
</div>
<a id="inline" href="#avatars"><img id="avatar" src="file.png" /></a>
<input type="hidden" name="avatar" value="" id="avatar" />
</fieldset>
So basically. I click on the link. The Fancybox shows up. I add text in the input (this is text), When I click the i will get this (in Firebug):
[input#search_avatar, input#search_avatar This is text]
When i execute this:
$('#search_avatar').val()
I get:
""
Thanks!