jquery - Facing issue in raty function -


hi using raty star rating in form in rails4 , using gem 'nested_form' create multiple star rating given follows

<%= f.fields_for :round_questions |question| %>          <%= question.label :question %>          <%= question.text_field :question %>         <div class="star-questions" > </div>                <%= question.text_field :answer %> <% end %>                        <%= f.link_to_add "add question", :round_questions,                                         :class=> 'btn waves-effect waves-light btn-medium custom_btn_gray', :id => "add-fields" %> 

and javascript given

$('.star-questions').raty({    target     :  $("input[id^='interview_round_round_questions_attributes_'][id$=_answer]"),     targettype : 'score',     targetkeep : true }); 

the browser getting html

<div class="fields">                            <label for="interview_round_round_questions_attributes_0_question" class="">question</label>                               <input type="text" name="interview_round[round_questions_attributes][0][question]" id="interview_round_round_questions_attributes_0_question">                             <div class="star-questions" style="cursor: pointer; width: 100px;"><img src="/assets/jquery.raty/star-off.png" alt="1" title="bad">&nbsp;<img src="/assets/jquery.raty/star-off.png" alt="2" title="poor">&nbsp;<img src="/assets/jquery.raty/star-off.png" alt="3" title="regular">&nbsp;<img src="/assets/jquery.raty/star-off.png" alt="4" title="good">&nbsp;<img src="/assets/jquery.raty/star-off.png" alt="5" title="gorgeous"><input type="hidden" name="score"></div>                         <input type="text" name="interview_round[round_questions_attributes][0][answer]" id="interview_round_round_questions_attributes_0_answer">   </div><div class="fields">                            <label for="interview_round_round_questions_attributes_1_question">question</label>                               <input type="text" name="interview_round[round_questions_attributes][1][question]" id="interview_round_round_questions_attributes_1_question">                             <div class="star-questions" style="cursor: pointer; width: 100px;"><img src="/assets/jquery.raty/star-off.png" alt="1" title="bad">&nbsp;<img src="/assets/jquery.raty/star-off.png" alt="2" title="poor">&nbsp;<img src="/assets/jquery.raty/star-off.png" alt="3" title="regular">&nbsp;<img src="/assets/jquery.raty/star-off.png" alt="4" title="good">&nbsp;<img src="/assets/jquery.raty/star-off.png" alt="5" title="gorgeous"><input type="hidden" name="score"></div>                         <input type="text" name="interview_round[round_questions_attributes][1][answer]" id="interview_round_round_questions_attributes_1_answer">   </div><div class="fields">                            <label for="interview_round_round_questions_attributes_2_question">question</label>                               <input type="text" name="interview_round[round_questions_attributes][2][question]" id="interview_round_round_questions_attributes_2_question">                             <div class="star-questions" style="cursor: pointer; width: 100px;"><img src="/assets/jquery.raty/star-off.png" alt="1" title="bad">&nbsp;<img src="/assets/jquery.raty/star-off.png" alt="2" title="poor">&nbsp;<img src="/assets/jquery.raty/star-off.png" alt="3" title="regular">&nbsp;<img src="/assets/jquery.raty/star-off.png" alt="4" title="good">&nbsp;<img src="/assets/jquery.raty/star-off.png" alt="5" title="gorgeous"><input type="hidden" name="score"></div>                         <input type="text" name="interview_round[round_questions_attributes][2][answer]" id="interview_round_round_questions_attributes_2_answer">   </div><div class="fields">                            <label for="interview_round_round_questions_attributes_3_question">question</label>                               <input type="text" name="interview_round[round_questions_attributes][3][question]" id="interview_round_round_questions_attributes_3_question">                             <div class="star-questions" style="cursor: pointer; width: 100px;"><img src="/assets/jquery.raty/star-off.png" alt="1" title="bad">&nbsp;<img src="/assets/jquery.raty/star-off.png" alt="2" title="poor">&nbsp;<img src="/assets/jquery.raty/star-off.png" alt="3" title="regular">&nbsp;<img src="/assets/jquery.raty/star-off.png" alt="4" title="good">&nbsp;<img src="/assets/jquery.raty/star-off.png" alt="5" title="gorgeous"><input type="hidden" name="score"></div>                         <input type="text" name="interview_round[round_questions_attributes][3][answer]" id="interview_round_round_questions_attributes_3_answer"> 

i using unique id happen when fill 1 of answer rating other 1 numbers displays. please guide me how solve this.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -