Connection between autocomplete and XenForo_ControllerPublic_Member::actionFind

chrisj

Active member
I noticed how even with this little html
PHP:
<input class="AutoComplete" />
XenForo was able to link it with XenForo_ControllerPublic_Member::actionFind.

How can I change this so that it will call actionFind for a different controller?

I probably have to understand XenForo_Template_Compiler_Tag_Admin_TextBoxUnit to do it but I was hoping someone could help explain it to me.
 
The action is in the javascript:

js/xenforo/full/xenforo.js

Code:
	XenForo.AutoComplete = function($element) { this.__construct($element); };
	XenForo.AutoComplete.prototype =
	{
		__construct: function($input)
		{
			this.$input = $input;

			if (XenForo.AutoComplete.defaultUrl === null)
			{
				if ($('html').hasClass('Admin'))
				{
					XenForo.AutoComplete.defaultUrl = 'admin.php?users/search-name&_xfResponseType=json';
				}
				else
				{
					XenForo.AutoComplete.defaultUrl = 'index.php?members/find&_xfResponseType=json';
				}
			}

If you are comfortable with javascript then you can write your own function to call a different action. Or you can extend XenForo_ControllerPublic_Member::actionFind to reroute to a different controller and action. You can reroute by having the controller return this:

Code:
return $this->responseReroute('YOU_ControllerPublic_YOURCONTROLLER', 'ACTION');
 
you don't need to:p

under the code from jake you'll find
Code:
this.url = $input.data('acUrl') || XenForo.AutoComplete.defaultUrl;

which means => add your own acUrl data field and enjoy it;)
 
Top Bottom