Hi Guys I have created a tabs by jquery and i want to display different data from database at each tab how can i do that knowing that it is the same container and same data but with different conditions hope to find an answer soon And i am using php and javascript Thanks
A:
Sounds like you just want to ajax the tab content based on which tab is clicked? Or do you really want diferent content when clicking the same tab, depending on some condition?
Nicky De Maeyer
2009-09-25 13:57:30
yes ajax tab content based on which one clicked how can i do this
Sarah
2009-09-27 15:07:05
+1
A:
you can set on event on the tabs (#('tabs').bind('tabselect', 'doSomething()')) and inside doSomething call an ajax method
Kheu
2009-09-25 14:07:35
+2
A:
I'd create a map of tab IDs to remote URLs you want to call when the tab is clicked. For example, in JS:
<script type="text/javascript">
var mySources = [];
mySources['home'] = '/ajax/getHome.php';
mySources['about'] = '/ajax/getAbout.php';
</script>
And, when your page is being built, it's easy to add the click listeners and ajax calls:
$(function(){
$("#myTabContainer a.tabLink").click(function(event){
event.preventDefault();
url = mySources[this.id];
$.get(url,null,
function(data){
// this is the data returned by the server,
// put it wherever it needs to go
}
);
});
});
Just my $.02, but that'd be how I'd start it, at least. Good luck!
inkedmn
2009-09-25 14:10:35