Last active
June 25, 2019 16:03
-
-
Save peterknolle/4f700563718188d15015 to your computer and use it in GitHub Desktop.
Input Rating Lightning Component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<aura:component > | |
<ltng:require scripts="/resource/rating/vendor/jquery.js,/resource/rating/lib/jquery.raty.js" | |
styles="/resource/rating/lib/jquery.raty.css" | |
afterScriptsLoaded="{!c.afterScriptsLoaded}"/> | |
<aura:attribute name="value" type="Integer" required="true"/> | |
<aura:attribute name="ready" type="Boolean" default="false"/> | |
<div aura:id="rating"></div> | |
</aura:component> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
afterScriptsLoaded : function(component, event, helper) { | |
component.set("v.ready", true); | |
helper.createRating(component); | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
createRating : function(component) { | |
// check in case coming from afterRender, | |
// before scripts are loaded | |
var ready = component.get("v.ready"); | |
if (ready === false) { | |
return; | |
} | |
var ratingElem = component.find("rating").getElement(); | |
$(ratingElem).raty({ | |
starType: "i", | |
score: component.get("v.value"), | |
click: function(score, evt) { | |
component.set("v.value", score); | |
} | |
}); | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
({ | |
afterRender: function(component, helper) { | |
this.superAfterRender(component, helper); | |
helper.createRating(component); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment