Artwork

Content provided by Charles Max Wood. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Charles Max Wood or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://ppacc.player.fm/legal.
Player FM - Podcast App
Go offline with the Player FM app!

Building a Star-Rating System in Ruby on Rails with jQuery

 
Share
 

Fetch error

Hmmm there seems to be a problem fetching this series right now. Last successful fetch was on January 12, 2023 20:49 (2+ y ago)

What now? This series will be checked again in the next day. If you believe it should be working, please verify the publisher's feed link below is valid and includes actual episode links. You can contact support to request the feed be immediately fetched.

Manage episode 312586913 series 3238400
Content provided by Charles Max Wood. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Charles Max Wood or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://ppacc.player.fm/legal.
Specification Clicking a star rating turns on the stars to the left of the star I clicked. Clicking a star submits the star rating. When I refresh the page, the star ratings should be persistent. We’ll be using Rails’ functions including: form_for hidden_field Rails Helpers We’ll be using jQuery functions including: click each ajax <% form_id = "movie_#{movie.id}_rating" %> <%= form_for movie.ratings.last || movie.ratings.build, :html => {:id => form_id , :class => "star_rating_form"} do |f| %> <%= f.hidden_field :movie_id %> <%= f.hidden_field :stars, :id => form_id + "_stars" %> <% end %> <% (1..5).each do |i| %>
  • <% end %> var set_stars = function(form_id, stars) { for(i=1; i <= 5; i++){ if(i <= stars){ $('#' + form_id + '_' + i).addClass("on"); } else { $('#' + form_id + '_' + i).removeClass("on"); } } } $(function() { $('.rating_star').click(function() { var star = $(this); var form_id = star.attr("data-form-id"); var stars = star.attr("data-stars"); $('#' + form_id + '_stars').val(stars); $.ajax({ type: "post", url: $('#' + form_id).attr('action'), data: $('#' + form_id).serialize() }) }); $('.star_rating_form').each(function() { var form_id = $(this).attr('id'); set_stars(form_id, $('#' + form_id + '_stars').val()); }); });
  •   continue reading

    80 episodes

    Artwork
    iconShare
     

    Fetch error

    Hmmm there seems to be a problem fetching this series right now. Last successful fetch was on January 12, 2023 20:49 (2+ y ago)

    What now? This series will be checked again in the next day. If you believe it should be working, please verify the publisher's feed link below is valid and includes actual episode links. You can contact support to request the feed be immediately fetched.

    Manage episode 312586913 series 3238400
    Content provided by Charles Max Wood. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Charles Max Wood or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://ppacc.player.fm/legal.
    Specification Clicking a star rating turns on the stars to the left of the star I clicked. Clicking a star submits the star rating. When I refresh the page, the star ratings should be persistent. We’ll be using Rails’ functions including: form_for hidden_field Rails Helpers We’ll be using jQuery functions including: click each ajax <% form_id = "movie_#{movie.id}_rating" %> <%= form_for movie.ratings.last || movie.ratings.build, :html => {:id => form_id , :class => "star_rating_form"} do |f| %> <%= f.hidden_field :movie_id %> <%= f.hidden_field :stars, :id => form_id + "_stars" %> <% end %> <% (1..5).each do |i| %>
  • <% end %> var set_stars = function(form_id, stars) { for(i=1; i <= 5; i++){ if(i <= stars){ $('#' + form_id + '_' + i).addClass("on"); } else { $('#' + form_id + '_' + i).removeClass("on"); } } } $(function() { $('.rating_star').click(function() { var star = $(this); var form_id = star.attr("data-form-id"); var stars = star.attr("data-stars"); $('#' + form_id + '_stars').val(stars); $.ajax({ type: "post", url: $('#' + form_id).attr('action'), data: $('#' + form_id).serialize() }) }); $('.star_rating_form').each(function() { var form_id = $(this).attr('id'); set_stars(form_id, $('#' + form_id + '_stars').val()); }); });
  •   continue reading

    80 episodes

    All episodes

    ×
     
    Loading …

    Welcome to Player FM!

    Player FM is scanning the web for high-quality podcasts for you to enjoy right now. It's the best podcast app and works on Android, iPhone, and the web. Signup to sync subscriptions across devices.

     

    Quick Reference Guide

    Listen to this show while you explore
    Play