Tool tip is not shown when the <input type="hidden" class="rating"/>
Tool tip is shown when the <input type="hidden" class="rating1"/>
MY codes are here
<input type="hidden" class="rating"/>
<script>
$('.rating').rating({
extendSymbol: function (rate) {
$(this).tooltip({
container: 'body',
placement: 'bottom',
title: 'Rate ' + rate
});
}
});
</script>
<input type="hidden" class="rating1"/>
<script>
$('.rating1').rating({
extendSymbol: function (rate) {
$(this).tooltip({
container: 'body',
placement: 'bottom',
title: 'Rate ' + rate
});
}
});
</script>
<style>
.symbol {
display: inline-block;
border-radius: 50%;
border: 5px double white;
width: 30px;
height: 30px;
}
</style>
The problem is because the plugin you use (really, really stupidly) automatically assigns itself to any elements with a class of .rating
with no parameters specified - see the last 4 lines of the code here: http://dreyescat.github.io/bootstrap-rating/bootstrap-rating.js
To fix you problem you simply need to give your input
a different class so it uses the settings you provide, not the default parameter-less initialisation. Try this:
<input type="hidden" class="star-rating" /> <!-- note the changed class -->
$('.star-rating').rating({
extendSymbol: function(rate) {
$(this).tooltip({
container: 'body',
placement: 'bottom',
title: 'Rate ' + rate
});
}
});
Also note that you can use a common class with a single jQuery selector to initialise the plugin on all elements. See the fiddle for an example.
I would also contact the plugin author and get them to remove the lines of code which automatically assign the plugin to anything with a .rating
class - it's a really dumb thing to do in a plugin for public use.