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

Auto load overlay

Discussion in 'XenForo Development Discussions' started by Syndol, Jan 9, 2012.

  1. Syndol

    Syndol Guest

    Hi, I am auto loading an overlay upon entering a page.
    I have registered the link and then call click() upon it.
    This works but it seems to call this function multiple times causing the overlay to flicker.

    So my question is:
    What is the proper way to auto load an overlay? :)

    Thank you.
  2. xfrocks

    xfrocks Well-Known Member

    What about call click() and set a flag so your script won't call click() a second time?
    Or better yet, you can extend XenForo_OverlayTrigger and call show() as soon as in __construct().
  3. Syndol

    Syndol Guest

    Tried that but it did not work.
    Also tried to defer it using XenForoActivationComplete
  4. EQnoble

    EQnoble Well-Known Member

    Played around with it and got an overlay to show on load of a xf page using this....

    given your <a> with the class of: OverlayTigger also has an id of: IDofClicker

    it's not pretty but i wasn't trying to style it, just wanted to see if it would click the overlay link on doc ready (is that the term for it?) and it does.
  5. Syndol

    Syndol Guest

    Simple yet effective.
    Thank you very much.
    I guess I was barking up the wrong tree.
  6. EQnoble

    EQnoble Well-Known Member

    When you find what is up there let me know...all I ever see is leaves :)

    I realized now that I could have made empty <a class="OverlayTrigger" id="IdofClicker"></a> that would open the overlay on page loads and yet not display anything on the page calling the overlay.
  7. Chris D

    Chris D XenForo Developer Staff Member

    Guys I found this thread after someone asked me basically the same thing. We'd already thought of getting jQuery to click the link but the objective was to have no link displayed on screen. It's worth noting that XenForo Resource Manager 1.1.0 triggers the click function on page load after a resource has been added to pop up the Edit Icon overlay. This isn't an issue because that link is already displayed on-screen anyway.

    So I looked into the functions in xenforo.js a little bit closer and it really isn't much more difficult than this:

                this.$trigger = { href : 'http://url-to-open-in-overlay.com' };
                this.$options = {};
                this.OverlayLoader = new XenForo.OverlayLoader($(this.$trigger), false, this.$options);
    You can of course analyse the code a little bit further to work out other parameters you can pass through to the OverlayLoader but as it stands the code above wrapped in an appropriate function should launch the specified overlay without user intervention and without any visual triggers.
    Syndol likes this.

Share This Page