Why I am getting a syntax error after trying to attach live() to jQueryUI tabs()?
Why do I get a Firebug syntax error when I change from this:
$( "#tabs" ).tabs({
to this:
<script>
$(function() {
$("#tabs").live('tabs', function(event){
ajaxOptions: {
error: function( xhr, status, index, anchor ) {
$( anchor.hash ).html(
"Couldn't load this tab. We'll try to fix this as soon as possible. " +
"If this wouldn't be a demo." );
}
}
});
});
</script>
<div class="demo">
<div id="tabs">
<ul>
<li><a href="#tabs-1">Name</a></li>
<li><a href="#tabs-2">Address</a></li>
</ul>
<div id="tabs-1">
<div id="dynamicContent">
John Doe
</div>
</div>
<div id="tabs-2">
Cupertino, California
</div>
</div>
</div><!-- End demo -->
I need a live()
fu开发者_JAVA技巧nction because I erase the inner HTML where the tabs element exists in the course of the page lifecycle.
tabs()
is not a setter of an event handler, it is just a method of the jQuery object. Live will set an event handler, so you cannot use it.
I don't think there is an easy way to create the tabs automatically; can't you create the tabs when new content is added?
精彩评论