Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8530035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:09:55+00:00 2026-06-11T09:09:55+00:00

I am trying to update a global javascript variable with a value from jsrender

  • 0

I am trying to update a global javascript variable with a value from jsrender template. How can I accomplish it…

i have created a fiddle http://jsfiddle.net/4RH7n/8/

i need to have the last movie name into that javascript variable..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:09:57+00:00Added an answer on June 11, 2026 at 9:09 am

    Custom tags and helpers can easily be registered to access or modify global variables. There is a sample here (code is here) which shows both ways, and illustrates both setting and getting globals from within a template. Helpers/custom tags are better than using {{* ...}} (since that way you have better separation of code and markup) – but if you do use {{* syntax you have to set allowCode=true. (See this example).

    The above approaches are ways of using your own extension to be able to access ANY global. However, for most scenarios, you probably only have certain specific globals you want to access. In that case it is really easy to pass the global(s) in as options on the .render() call (or the .link() call if you are using JsViews) like this:

    ...render(myData, { foo: myFooGlobal, bar: myBarGlobal });
    

    and then access them in any expression within the template, such as like this:

    ... {{:~foo}} ... {{for ~bar}} ... {{/for}} ...
    

    If you want to be able to access those globals from all your templates, (or for all calls to a specific template) you can instead register them as global (or template specific) helpers/template parameters, and then you don’t need to pass them in with the render/link call.

    For example, to register them globally, for all templates:

    $.views.helpers({
        foo: myFooGlobal,
        bar: myBarGlobal 
    });
    

    You then access them in exactly the same way as above, using ~foo (or foo() for a function).

    You’ll find sample of all of these approaches on GitHub.


    UPDATE:

    In addition to the documentation and samples referenced above, there are much more recent documentation and samples on http://www.jsviews.com, and specifically here and here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to update global javascript variables from ASP.NET code. What I've tried to
I am trying to pass a value to a global variable. This is where
I'm trying to carry a change from a global variable over to another module
When trying to update a subversion working copy from Netbeans, I get the following
I am trying to update the value of a column where it matches a
I am trying to update a database with values from a csv file, the
I'm trying to do more OOP in Javascript. One thing i can't figure out
I'm trying to programmatically extract some data from this url: http://www.treasurydirect.gov/NP/BPDLogin?application=np The issue is
I am trying to work with a global variable in Flex and it does
I'm trying to create a global (singleton) class that can associate any type of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.