2011-02-16 68 views
0

我已经使用了网页上的标签GUI:ASP.Net + JQuery的选项卡:使用Cookie选项打破我的GUI

  • 的JQuery 1.4.2
  • jQuery的UI 1.8.9(全下载)

'窗格'div的ID是数据库中域对象的GUID。一切正常。

但是当我包括在函数调用上

$(document).ready(function() { 
    //$("#tabs").tabs(); //Without tabs works fine 

    $("#tabs").tabs({ //This call with cookie option breaks everything. 
     cookie: { 
      expires: 1 
     } 
    }); 
}); 

cookie选择通过“游”我的意思是 - 我的最后一个选项卡的内容(其中包括一个“提交”按钮)最终被在显示每个选项卡页面的底部,尽管选项卡本身看起来不错。单击时没有任何选项卡会打开相应窗格,但是当单击选项卡时,我可以在浏览器的地址栏中看到正确的选项卡标识。

我比较两个页面的源(有和没有cookie选项),他们是相同除了调用了jQuery tab功能。

不过的JavaScript控制台报告一个错误:

cannot call method 'apply' of undefined 

是否有别的东西,我需要做的就是这个工作?该文档建议不...

我已经插入了Nalum建议的cookies插件,但这并没有解决问题。

钻进jquery-ui-1.8.9.custom.min.js让我问题的代码位:

return d.cookie.apply(null,[b].concat(d.makeArray(arguments ... 

此代码似乎在期待[b]是像ui-tabs-1这其中,如果您通过添加标签的选项卡IDed方式tabs.add(...)功能。当然,我不会通过这种方式添加我的选项卡 - 我的所有选项卡都有GUID ID,这些ID与来自数据库的元素相关,并由Repeater控件输出。

下面的一些HTML以供参考:

<div id="tabs"> 
    <ul>    
     <li> 
      <a href='#TabDiv471de30d-aaec-4485-8a50-1b2fdbc58053'> 
       Tab A 
      </a> 
     </li> 
     <li> 
      <a href='#TabDiv951e2fee-9272-4a8c-becb-3f3a07770347'> 
       Tab B 
      </a> 
     </li> 
    </ul> 
    <div id='TabDiv471de30d-aaec-4485-8a50-1b2fdbc58053'> 
     This is Pane A 
    </div> 
    <div id='TabDiv951e2fee-9272-4a8c-becb-3f3a07770347'> 
     This is Pane B 
    </div> 
</div> 

回答

1

jQuery UI Docs,注:需要cookie的插件。

Store the latest selected tab in a cookie. The cookie is then used to determine the initially selected tab if the selected option is not defined. Requires cookie plugin. The object needs to have key/value pairs of the form the cookie plugin expects as options. Available options (example): { expires: 7, path: '/', domain: 'jquery.com', secure: true }. Since jQuery UI 1.7 it is also possible to define the cookie name being used via name property.

+0

感谢您的回答。 我从http://plugins.jquery.com/project/Cookie下载了jquery-cookies.js并将它包含在我的页面中。它似乎没有任何区别 - 有什么我需要做的才能让它工作? – 5arx 2011-02-17 10:36:20

相关问题