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

Calling XenForo javascript functions outside of instance

Discussion in 'XenForo Development Discussions' started by Daniel Hood, Jan 20, 2016.

  1. Daniel Hood

    Daniel Hood Well-Known Member

    Basically I'm trying to call
    XenForo.AutoComplete.results.selectResult(-1, true);
    from outside of the AutoComplete class.

    More specifically I need to call it for just the search bar. I tried specifying $('#QuickSearchQuery').AutoComplete.results.selectResult(-1, true); but that returns that AutoComplete is not a function. I also tried XenForo['AutoComplete']($('#QuickSearchQuery')).

    Is there a way to call methods within functions that run through XenForo.register()?
    Xon likes this.
  2. Daniel Hood

    Daniel Hood Well-Known Member

    Nevermind. Figured it out right after posting.. figures.

    Anyone else interested, you can call:

    $('#QuickSearchQuery').data('XenForo.AutoComplete'); // Or whatever the function name is.
    Xon likes this.

Share This Page