jQuery UI Widgets Forums Vue JqxForm TypeError Cannot read properties of undefined (reading 'val')

This topic contains 1 reply, has 2 voices, and was last updated by  svetoslav_borislavov 10 months, 1 week ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • jqwidgetsdev
    Participant

    Hi,

    Can you please look at this issue.

    TypeError Cannot read properties of undefined (reading ‘val’)

    <template>
      <JqxForm ref="myForm" :template="template"> </JqxForm>
    </template>
     
    <script>
    import JqxForm from "jqwidgets-scripts/jqwidgets-vue/vue_jqxform.vue";
    import data from "./assets/data.json"; //import json data
    
    export default {
      components: {
        JqxForm,
      },
      mounted: function () {
        const myForm = this.$refs.myForm;
        const btn = myForm.getComponentByName("btn");
        btn.on("click", function () {
    
          if (typeof myForm.getComponentByName("xxxx") !== "undefined") {
            //set the input value to the data
            myForm.getComponentByName("xxxx").val("data"); 
          }
        });
      },
      data: function () {
        return {
          template: [
            {
              bind: "xxxx",
              type: "label",
              label: "some label",
              labelPosition: "left",
              labelWidth: "30%",
              align: "left",
              width: "250px",
            },
            {
              name: "btn",
              type: "button",
              text: "btn",
              align: "left",
              padding: { left: 0, top: 5, bottom: 5, right: 40 },
            },
          ],
        };
      },
    };
    </script>

    Thanks.

    Hi,

    GetComponentByName will search for a property ‘name’, but the key of ‘xxxx’ is ‘bind’. You should rename it to ‘name’.
    Also, the val() method is applied to the form.
    Check this example and see: https://codesandbox.io/s/gracious-rgb-5hw7fp

    If you need any help, let us know!

    Best regards,
    Svetoslav Borislavov

    jQWidgets Team
    https://www.jqwidgets.com/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.