Hello,
I have been trying to get this working for the last 7 hours so please excuse the slight tone of frustration.
I have successfully implemented a nice set of jquery ui tabs that load their content via ajax.
The content loaded via ajax features a form. I wanted the first field in the form (which has an ID of #title) to be focused automatically when the tab is loaded. This didnt work when I tried putting the script in the external document so I thought a callback would be a good idea.
setTimeout( function() { $("#title").focus(); }, 500 );
I got this idea from here. The delay is because i was experiencing problems with the field not focusing properly when clicking through each tab. At first I thought this had solved some of the problem, however after even more testing I found that this focus field works only on the tab that was initially loaded.
I decided to clear my head and implement a nice jquery autocomplete text field.
This script seemed to work when loaded straight into the external content, but to my dismay further testing showed this not to be the case. The autocomplete field works only on the tab that is loaded when the page is loaded.
This is when I noticed the pattern that both my scripts are only working on the initial loaded tab.
I have tried using the select, load and show events but all fail to work.
I know the callback is working because the alert is appearing when each tab is clicked.
Obviously I am doing something very wrong.
Please pick my code to pieces and tell me what I am doing wrong.
<script type="text/javascript">
$(function() {
$("#tabs").tabs({
load: function(event, ui) { setTimeout( function() { $("#title").focus(); }, 500 );
$("#role").autocomplete(
"/profile/autocomplete",
{
delay:10,
minChars:1,
matchSubset:1,
matchContains:1,
cacheLength:10,
onItemSelect:selectItem,
onFindValue:findValue,
formatItem:formatItem,
autoFill:true
}
);
alert('callback');
}
});
});
</script>