I am using vanilla Meteor (using Blaze, not React, Angular or Vue) and jQuery. I have Survey Creator working just fine using code that is similar to what you see below. However, I'm building a page to display the survey, and survey-jquery gives me the error "Survey.Model is not a constructor". My code is fairly simple:
JavaScriptimport { Template } from "meteor/templating"
import $ from 'jquery'
import { Survey, Model } from 'survey-jquery'
import './survey-form.html'
Template.surveyForm.onRendered(function() {
const template = Template.instance()
const surveyData = {
"pages": [
{
"name": "page1",
"elements": [
{ "type": "text", "name": "question1" }
]
}
]
}
let surveyInstance = new Survey.Model(surveyData)
template.$("#surveyFormContainer").Survey({
model: surveyInstance,
onComplete: function todo () {}
})
})
Any help would be appreciated. Because this is Meteor, I cannot easily send you a Plunker to demonstrate the problem.
Hello,
I've not tested it (right now) but I think it should look lile
import { Model } from 'survey-jquery'
or
import * as Survey from 'survey-jquery'
Thanks, Serge
SurveyJS Team
My original import:
import { Survey, Model } from 'survey-jquery'
Suggestion #1:
import { Model } from 'survey-jquery'
Throws the error: "Survey is not defined"
Suggestion #2:
import * as Survey from 'survey-jquery'
Yay! It works! Thank you.
Paul
On 10/9/2019 11:14:50 AM, Support Support <
Hello,
Thats good! Please feel free to contact us in case of any further questions
Thanks, Alex
SurveyJS Team