Skip to content

Commit

Permalink
fix: starControl did not save nor load userData
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasnetau committed Oct 9, 2023
1 parent 64dfde5 commit a12603d
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/js/control_plugins/starRating.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,32 @@ window.fbControls.push(function(controlClass) {
* javascript & css to load
*/
configure() {
this.js = '//cdnjs.cloudflare.com/ajax/libs/rateYo/2.2.0/jquery.rateyo.min.js'
this.css = '//cdnjs.cloudflare.com/ajax/libs/rateYo/2.2.0/jquery.rateyo.min.css'
this.js = 'https://cdnjs.cloudflare.com/ajax/libs/rateYo/2.3.2/jquery.rateyo.min.js'
this.css = 'https://cdnjs.cloudflare.com/ajax/libs/rateYo/2.3.2/jquery.rateyo.min.css'
}

/**
* build a text DOM element, supporting other jquery text form-control's
* @return {HTMLElement} DOM Element to be injected into the form.
* @return {HTMLElement|Object|HTMLElement[]} DOM Element to be injected into the form.
*/
build() {
this.dom = this.markup('span', null, { id: this.config.name })
return this.dom
this.input = this.markup('input', null, { ...this.config, type: 'hidden', })
this.field = this.markup('span')
return [this.input, this.field]
}

/**
* onRender callback
*/
onRender() {
const value = this.config.value || 3.6
$(this.dom).rateYo({ rating: value })
const value = this.config.userData ? this.config.userData[0] : this.config.value || 3.6
const input = $(this.input)
$(this.field).rateYo({
rating: value,
onSet: function(rating) {
input.val(rating)
}
})
}
}

Expand Down

0 comments on commit a12603d

Please # to comment.