开发者

Why I am getting a syntax error after trying to attach live() to jQueryUI tabs()?

开发者 https://www.devze.com 2023-01-27 01:05 出处:网络
Why do I get a Firebug syntax error when I change from this: $( \"#tabs\" ).tabs({ to this: <script>

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消