0

Access and set klipfolio variable

Hi. 

Working with dynamic datasources in an html component, is it possible to access a klipfolio variable - and set its value with e.g. an onclick event. ?

If so how would one go about doing this?

It would help alot, just knowing if you can actually manipulate klipfolio variables in html/javascript?

 

 

7 comments

  • 0
    Avatar
    Janice Janczyn

    Hi Kenneth,

    The Javascript in your HTML template can indirectly use variables, but it cannot set them. The Javascript can refer to Data subcomponents which can in turn refer to variables just like any other Klip type. For example, in the HTML Template klip

         Data: item1
             data reference/formula that uses a variable

        HTML template:
              <ul id="html-item1" ;">
              {{each data}}
              <li>${$value.item1}</li>
              {{/each}}
              </ul>

         Script:
              var item1 = $("#html-item1 li");

    What are you trying to do that requires setting a variable? There may be an alternate approach.

    Thank you,
                Janice

     

  • 0
    Avatar
    Peter Vermeulen

    Hi,

     

    Not sure what Kenneth's is trying to do but in my case I would like to update an existing Pie chart with values that are being calculated with an external javascript.

     

    Regards,
    Peter

  • 0
    Avatar
    Janice Janczyn

    Hi Peter,

    Could you please provide more details about what you're trying to do? I assume the javascript is in an HTML component and the pie chart  is a standard Pie Chart component? If they are contained in the same multicomponent klip it may be possible to assign the results of the javascript to a variable that the pie chart can then use.

    Thanks,
            Janice

  • 0
    Avatar
    Peter Vermeulen

    Hi Janice,

    Your assumption is correct, a precise description of what we would like to achieve.

    I have an example klip available where we use a Google Drive datasource (spreadsheet). Want to send the data to an interpreter (javascript) and use it in KF piechart.

    I can share the example klip by email.

     

    Regards,
    Peter

  • 0
    Avatar
    Janice Janczyn

    Hi Peter, 

    Please email support@klipfolio.com with the details and we'll see if there is a way to achieve what you're trying to do. 

    Thank you,
                 Janice

  • 0
    Avatar
    pm thwin

    Hello,

    How can I use the variable of user input control in my java-script code of html template component?

    I've tried with $variable1. But it doesn't work.

    Thank you.

  • 0
    Avatar
    Peter Vermeulen
Please sign in to leave a comment.