In a nutshell, the best approach to tackle this issue is by utilizing the latest update of Raty (version 2.7.0) (as of the most recent edit on this answer) and exploring the 'starType' attribute. When configuring the element, follow these steps:
$('div').raty({
// Alter the tag from image to icon with this configuration
starType : 'i'
});
Diving deeper into details... A thorough examination of the CSS file and the font files reveals how the <i>
tag is set up to coincide with a specific font. Subsequently, it becomes straightforward to identify the content associated with each class's :before
. Start off by ensuring FontAwesome is added, then configure your CSS as follows (specifically for FontAwesome):
.cancel-on-png, .cancel-off-png, .star-on-png, .star-off-png, .star-half-png {
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
/*This section is crucial*/
font-family: "FontAwesome";
font-style: normal;
font-variant: normal;
font-weight: normal;
line-height: 1;
speak: none;
text-transform: none;
}
.cancel-on-png:before {
/*"\f057" represents an empty circle with an x inside*/
/*Each of these can be customized to any desired icon*/
/*For further information on icon codes, refer to the linked source below*/
content: "\f057";
}
/*Remaining classes defined similarly*/
A comprehensive rundown of CSS content values for FontAwesome is available here
The final outcome would resemble something along these lines:
<div>
<i title="Cancel this rating!" class="raty-cancel cancel-off-png" data-alt="x"></i>
<i data-alt="1" class="star-off-png" title="Bad"></i>
<i data-alt="2" class="star-off-png" title="Below Average"></i>
<i data-alt="3" class="star-off-png" title="Average"></i>
<i data-alt="4" class="star-off-png" title="Above Average"></i>
<i data-alt="5" class="star-off-png" title="Great"></i>
<input name="score" type="hidden">
</div>
Configuration should align with:
$(div).raty({
readOnly : readOnly,
cancel : !readOnly,
noRatedMsg : 'This component has not been rated yet',
half : true,
starType : 'i',
hints : ['Bad', 'Below Average', 'Average', 'Above Average', 'Great'],
click : function(score, event) {
console.log("The score is:", score);
}
});
I realize it's been a while, but I trust this information proves beneficial!