1

I have a this working countdown timer in jQuery but for now I'm just statically setting the target date but I need to set the target date using an attribute from my instance variable, but the value is not showed on the page so I guess can't get it directly by using $("#date")...I need something like this:

$('#countdown_dashboard').countDown({
    targetDate: {
       'min': my_instance_date_min
    }
)}

1 Answer 1

2

If I understand the question correctly, you want an instance variable in your controller to determine the target date for your countdown timer. If that's the case, then just render it in your view either as a hidden form element, or as a page element with display:none. Consider this code:

<form>
  <%= hidden_field_tag "ivar_date", @ivar_date %>
</form>

That gets you your hidden element with the value of in instance variable. Then in your jQuery, you can just:

'min': $('#ivar_date').value()

to get the date in your timer.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.