Artwork

Inhalt bereitgestellt von Charles Max Wood. Alle Podcast-Inhalte, einschließlich Episoden, Grafiken und Podcast-Beschreibungen, werden direkt von Charles Max Wood oder seinem Podcast-Plattformpartner hochgeladen und bereitgestellt. Wenn Sie glauben, dass jemand Ihr urheberrechtlich geschütztes Werk ohne Ihre Erlaubnis nutzt, können Sie dem hier beschriebenen Verfahren folgen https://de.player.fm/legal.
Player FM - Podcast-App
Gehen Sie mit der App Player FM offline!

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

 
Teilen
 

Fetch error

Hmmm there seems to be a problem fetching this series right now. Last successful fetch was on January 12, 2023 20:49 (3y 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
Inhalt bereitgestellt von Charles Max Wood. Alle Podcast-Inhalte, einschließlich Episoden, Grafiken und Podcast-Beschreibungen, werden direkt von Charles Max Wood oder seinem Podcast-Plattformpartner hochgeladen und bereitgestellt. Wenn Sie glauben, dass jemand Ihr urheberrechtlich geschütztes Werk ohne Ihre Erlaubnis nutzt, können Sie dem hier beschriebenen Verfahren folgen https://de.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 Episoden

    Artwork
    iconTeilen
     

    Fetch error

    Hmmm there seems to be a problem fetching this series right now. Last successful fetch was on January 12, 2023 20:49 (3y 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
    Inhalt bereitgestellt von Charles Max Wood. Alle Podcast-Inhalte, einschließlich Episoden, Grafiken und Podcast-Beschreibungen, werden direkt von Charles Max Wood oder seinem Podcast-Plattformpartner hochgeladen und bereitgestellt. Wenn Sie glauben, dass jemand Ihr urheberrechtlich geschütztes Werk ohne Ihre Erlaubnis nutzt, können Sie dem hier beschriebenen Verfahren folgen https://de.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 Episoden

    Alle Folgen

    ×
     
    Loading …

    Willkommen auf Player FM!

    Player FM scannt gerade das Web nach Podcasts mit hoher Qualität, die du genießen kannst. Es ist die beste Podcast-App und funktioniert auf Android, iPhone und im Web. Melde dich an, um Abos geräteübergreifend zu synchronisieren.

     

    Kurzanleitung

    Hören Sie sich diese Show an, während Sie die Gegend erkunden
    Abspielen