Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

Is possible to check boolean value by JS?

Javascript • Asked by Dmitry Amelchenko

In Rails 4 app i need to implement bootstrap modal when user comes for first time and accept the terms.
I'm trying to do something like this:

= content_tag :body, data: { accept_terms: current_user.accept_terms? } do

current_user.accept_terms? - just instance method returns true or false

$(document).on 'page:change', ->
return unless $('body').data('accept-terms')
$('.terms-modal').modal 'show'

Yep, something like that could work. That should print out true or false in the data attribute (you can inspect the html to verify) and sure give you back a Javascript boolean you can use when you query for it.

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 29,763+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.