Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure languages are loaded before rendering forms #1590

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions src/js/form-render.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ class FormRender {
this.options = jQuery.extend(true, defaults, options)
this.instanceContainers = []

//Override any sanitizer configuration
setSanitizerConfig(this.options.sanitizerOptions)

this.mi18nLoading = null
if (!mi18n.current) {
mi18n.init(this.options.i18n)
this.mi18nLoading = mi18n.init(this.options.i18n)
}

//Override any sanitizer configuration
setSanitizerConfig(this.options.sanitizerOptions)

// parse any passed formData
if (this.options.formData) {
this.options.formData = this.parseFormData(this.options.formData)
Expand Down Expand Up @@ -186,7 +187,7 @@ class FormRender {
* @param {number} instanceIndex - instance index
* @return {Object} rendered form
*/
render(element = null, instanceIndex = 0) {
async render(element = null, instanceIndex = 0) {
const formRender = this
const opts = this.options
element = this.getElement(element)
Expand All @@ -197,6 +198,11 @@ class FormRender {
}
}

if (this.mi18nLoading) {
await this.mi18nLoading
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

this.mi18nLoading = null
}

// Begin the core plugin
const rendered = []

Expand Down
Loading