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

Javascript + XenForo Options

Discussion in 'XenForo Development Discussions' started by Daniel Hood, Aug 13, 2013.

  1. Daniel Hood

    Daniel Hood Well-Known Member

    Are the options set in the admin panel accessible through the XenForo javascript object? I tried
    Code:
    console.log(XenForo.options);
    but it said undefined.
     
  2. Jeremy

    Jeremy XenForo Moderator Staff Member

    Doesn't look like its available, no.
     
  3. Daniel Hood

    Daniel Hood Well-Known Member

    hmmm... alright. Is there a buildLink function or something I can use then? I needed options for something else but I also need to be able to build a path.
     
  4. Chris D

    Chris D XenForo Developer Staff Member

    Best thing to do is use data- attributes on HTML elements if appropriate.

    They're used a lot in XenForo. Mostly to pass options and other data to JavaScript functions.
     
    Jeremy and Daniel Hood like this.
  5. Jeremy

    Jeremy XenForo Moderator Staff Member

    Yup, I concur with data-attributes. They are extremely useful when it comes to storing necessary information (XenForo uses them extensively).
     
    Daniel Hood likes this.
  6. Daniel Hood

    Daniel Hood Well-Known Member

    Thanks for the help guys.
     

Share This Page