开发者

Help with jQuery cookie and Drupal 7

I am using this sample code found 开发者_如何学Gohere, http://jaaulde.com/test_bed/stickytab/, and inserting in to a custom. js file to be used by my Drupal 7 install. I have the Omega theme running, and I'm successfully calling the script through my .info file.

The cookie works as intended, but obviously something is wrong because

  • I see a Javascript error message when viewing the site in IE
  • having this script causes problems on my Drupal site with IMCE.

This the code I'm using:

(function ($) {
  Drupal.behaviors.omega_musicians = {
    attach: function(context,settings) {
      var cookieName, $tabs, stickyTab;

      cookieName = 'stickyTab';
      $tabs = $('#tabstoo');
      $tabs.tabs({select: function( e, ui ) {
        $.cookies.set(cookieName, ui.index);
      }});
      stickyTab = $.cookies.get(cookieName);

      if(!isNaN(stickyTab)) {
        $tabs.tabs('select', stickyTab);
      }
    } //eof attach
  };
})(jQuery);


Besides the fact (to consider) that there is an issue with apache's mod_secure and cookies, the ($) means the document and thus cookies is cookie (singular). You can check the DOM from firebug to figure out the syntax. A lot of (attached behaviors) function (eg Drupal.toolbar.toggle) is using it. I'm on the same pursuit and that's a short of clue for me about Drupal's js cookies.
Hope that helps.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜