Note that there are some explanatory texts on larger screens.

plurals
  1. POBackbone.js, updating rating
    primarykey
    data
    text
    <p>I'm making a small website for school, it's an image based gallery where you can vote and comment. At the moment they're all on one page and all have a rating form.</p> <p>So at the moment the default rating is working, but I cant update it (I frankly don't know how) Here's how it looks now</p> <p><a href="http://i.imgur.com/M4ZOtUG.png" rel="nofollow">http://i.imgur.com/M4ZOtUG.png</a></p> <p>The user is supposed to enter a rating, and then it should show the new value of the rating.</p> <p>I'm pretty close since when I rate the first image 3; I get: (in my console)</p> <p>"c1, 3"</p> <p>And when I rate the 4th image 5, I get:</p> <p>"c4, 5"</p> <p>etc.</p> <p>Now how do I update the default rating? (default ratings are set in my collection)</p> <p>Example code of image in collection</p> <pre><code>{image: "images/gifs/water.gif", rating: 5, comments: "Love the detail in this one!", title:"Water", category:"Nature"} </code></pre> <p>Here's how it's in my view:</p> <pre><code>gifs_html += '&lt;td&gt;' + "&lt;span class=\"stars\"&gt;" + gifs[gif].get("rating") + ".0&lt;/span&gt;" + "\n" + "&lt;form data-id=\"" + gifs[gif].cid + "\"&gt;&lt;input type=\"text\" name=\"amount\" size=\"5\" value=\"\"/&gt;" + "\n" + "&lt;input type=\"submit\" value=\"Rate\"&gt;" + "&lt;input type =\"hidden\" name=\"cid\" value=\"" + gifs[gif].cid + "\"&gt; &lt;/form&gt;" + '&lt;/td&gt;'; </code></pre> <p>Then I'm giving this jquery function (to update the star image)</p> <pre><code>$('span.stars').stars(); </code></pre> <p>and this event</p> <pre><code> events:{ 'submit form':function(ev){ var $form = $(ev.currentTarget); var id = $form.data("id"); var rating = $("input[name=amount]", $form).val(); console.log(id + ", " + rating); return false; } </code></pre> <p>Help would be greatly appreciated. Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload