开发者

Is the JQuery cookie plugin able to use custom aliases?

I am trying to use the JQuery cookie plugin in my project but I'm running into some trouble. Because I need to use the pr开发者_StackOverflowototype library along with the JQuery library I used the JQuery.noConflict() method to assign $j as the JQuery alias. Unfortunately, even once I have loaded jquery.cookie.js into my page, $j.cookie('name','value') returns

Uncaught TypeError: Object function (selector, context){
  //The JQuery object is actually just the init constructor 'enhanced'
  return new JQuery.fn.init(selector,context);
} has no method 'cookie'


It doesn't look like it is out of the box. Though, I'm sure it's possible for you to change it up a bit. Replace the instances of jQuery with '$' for instance in a block as such

(function($) {
  $.cookie = ...
})(jQuery);

I don't see why that wouldn't work, but I have no idea. I'm just speculating ;)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜