jquery-bar-rating icon indicating copy to clipboard operation
jquery-bar-rating copied to clipboard

Not able to use 0 value for rating

Open stanlyabraham opened this issue 6 years ago • 4 comments

I have the definition like below. I use -1 as no selection in the back-end and use knockout binding. I want to use a rating as 0 (0-5 rating) and clicking on a selected value should deselect all (that is why I have <option value=""></option>) . I tried with initialValue, allowEmpty etc. and none of them is helping. The only way I can make it work is set 0 option value to something else (e.g. ).

Is there a way to use 0 rating?

<select data-bind="value: rank" class="barrating"> <option value=""></option> <option value="-1"></option> <option value="-99">0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select>

stanlyabraham avatar Mar 18 '18 16:03 stanlyabraham

This worked for me, I basically added a hidden option with 0 to my select and added allowEmpty the options. Not sure if it's the best approach, but it worked for what I needed.

e.g:

<select class="rating" data-current-rating="0" name="rating">
	<option hidden="" value="0">0</option>
	<option value="1">1</option>
	<option value="2">2</option>
	<option value="3">3</option>
	<option value="4">4</option>
	<option value="5">5</option>
</select>

Options

allowEmpty: true,
emptyValue: 0,

User934903920432 avatar Mar 19 '18 13:03 User934903920432

Sorry, that is not helping. If I don't have <option value=""></option> it will not let me unselect

stanlyabraham avatar Mar 19 '18 13:03 stanlyabraham

Are there any update on this?

QuanTran91 avatar Aug 28 '18 03:08 QuanTran91

any update on this?

cesarmtz93-wit avatar Feb 05 '21 18:02 cesarmtz93-wit