Sha256: 7be0561eb4f7707e93634fabe24defe6b00536300cf6b6209bfe4df2b7aca82f
Contents?: true
Size: 707 Bytes
Versions: 75
Compression:
Stored size: 707 Bytes
Contents
export class RequiredFields { // Monitors the form and runs the callback if any of the required fields change constructor(form, callback) { this.form = form this.callback = callback this.reload() } get areComplete() { return this.requiredFields.filter((n, elem) => { return this.isValuePresent(elem) } ).length === 0 } isValuePresent(elem) { return ($(elem).val() === null) || ($(elem).val().length < 1) } // Reassign requiredFields because fields may have been added or removed. reload() { // ":input" matches all input, select or textarea fields. this.requiredFields = this.form.find(':input[required]') this.requiredFields.change(this.callback) } }
Version data entries
75 entries across 75 versions & 2 rubygems