• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XenForo.register(), XenForo.activate() and $.context()...

Mr. Goodie2Shoes

Well-known member
#1
So I am creating a prototype object to 'manage' my form and the code looks something like:
Code:
MyObj.MyFunc = function($form) { this.__construct($form); };
MyObj.MyFunc.prototype =
{
  __construct: function($form)
  {
  console.log('bleh');
  XenForo.register($form.find('.steps'), $.context(this, 'bleh'));
  XenForo.activate($form);
  },
  bleh: function($element)
  {
  console.log('yolo');
  console.log($element);
  }
};

XenForo.Register('.StuffEditor', 'MyObj.MyFunc');
The 'bleh' function only gets called after I added 'XenForo.activate($form)'.

Anyways, the problem I am currently facing is that the log for 'console.log($element)' is returning 0.

I am not good with javascript so be nice guys :p
 

Mr. Goodie2Shoes

Well-known member
#2
Upon investigating the arguments that were given while calling the 'bleh' function, I found that there are two args being passed, the first is 0 and the second one is the object that was supposed to be passed as the first variable... o_O