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

  • SEARCH
  • Home
  • 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 8962353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:06:31+00:00 2026-06-15T16:06:31+00:00

I am trying to pass a json object from a rails (.erb) view to

  • 0

I am trying to pass a json object from a rails (.erb) view to javascript.

Here is what my view looks like:

<p>
  <%= content_tag "div", id: "slider", data: {slider: {min: 1, max: 10}} do%>
  <%end%>
</p

And my javascript:

jQuery ->
  $('#slider').slider($('#slider').data('slider'))

How do I pass {min: 1, max:1} to my coffeescript file?

thanks

  • 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-15T16:06:31+00:00Added an answer on June 15, 2026 at 4:06 pm

    Check out this rails cast, and specifically the gon gem.

    Also your tag is generating a div with a data attribute. After your page loads find your div using jquery and query for the data attribute value. Once you have that you can do whatever you want with it.

    If your jquery is in your erb file, then it will load before your coffeescript, so you could then just store it in a variable and have it be the return value of your function. Then you can call that function from your coffeescript file to get the value.

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

Sidebar

Related Questions

I am trying to pass a simple JSON object to a controller using MVC3
I'm trying to pass an Int value pulled from a JSON String to reduce
I'm trying to create a JSON object on client-side and pass to a server-side
Im trying to pass these json object to the code behind var obj =
I'm trying to iterate in a JSON object that is returned from a PHP
What I'm trying to do is to pass JSON object to a WebAPI ajax
I am trying to pass JSON data from the client browser to an ASP.NET
I'm trying to use a rendered view in a JSON object and then return
I'm trying to create a json object from MySQL results, but not getting the
I'm trying to create a JSON object on form submit to pass to Perl.

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.