Question T1573
Visible to All Users

Some custom widgets don't respect "display" mode

created 6 years ago

[Ticket cloned from T1557: Getting data of current page on press of next or previous]

Thanks ,
I need to manipulate the markup of the **custom widget ** if view mode is display .
Currently i'm doing this :-

JavaScript
surveyModel.onAfterRenderQuestion.add((survey, options) => { if(options.question.customWidget!=null){ console.log("disable input box here") } })

Is this the correct method to call in order manipulate the markup ?

Comments (1)

    Could you tell us - what exact widgets don't support display mode and we'll fix it in the surveyjs/widgets repository.

    Thanks, Serge
    SurveyJS Team

    Answers

    created 6 years ago

    It is a custom made widget i am trying to make that makes an api call to check some data .

    JavaScript
    var widget_check = { name: "checkData", title: "test-check-data", iconName: "icon-text", widgetIsLoaded: function () { return true; }, isFit: function (question) { return question.getType() === 'checkData'; }, activatedByChanged: function (activatedBy) { Survey.JsonObject.metaData.addClass("checkData", [], null, "text"); }, isDefaultRender: false, htmlTemplate: '<input type="text">', afterRender: function (question, element) { element.onblur = function () { checkData(element.value) } function checkData(data) { //ajax requst to check some data from api } }, willUnmount: function (question, el) { } } Survey.CustomWidgetCollection.Instance.addCustomWidget(widget_check, "customtype");
      Comments (1)

        Hello,

        You need to set initial read only option and subscribe the readOnlyChangedCallback:

        JavaScript
        if (question.isReadOnly) { signaturePad.off(); } question.readOnlyChangedCallback = function() { if (question.isReadOnly) { signaturePad.off(); } else { signaturePad.on(); } };

        Examples you can find in the https://github.com/surveyjs/widgets/ repo (https://github.com/surveyjs/widgets/blob/master/src/signature_pad.js))

        Thanks, Serge
        SurveyJS Team