How do I get the id of an input created by jsonform?

Asked

Viewed 34 times

1

Personal how do I get the id of an input created from a Json with the Jsonforms documentation plugin here. It uses Schemas and Forms to dynamically assemble html, but I’m not able to work with input id, I need to validate the fields with the event Blur. Here is an example of a schema created:

 function getSchemaNFI(dataMap) {

 var formObject = {
   "schema": {
     "RazaoSocialDoTomador": {
        "type": "string",
        "title": "Razão Social do Tomador"
    }
 },

 "form": [
     {
        "type": "fieldset",
        "title": "Tomador",
        "items": [            
          "RazaoSocialDoTomador"
        ]
    }
 ],

"value": {
    "RazaoSocialDoFornecedor": getFromDataMap("RazaoSocialDoFornecedor", dataMap),
}

  "params": {
    "fieldHtmlClass": "input-text"
  }
};

return formObject;
}

1 answer

0

next, for you to be able to get the id of ANY element.... just use the ATTR function of jquery example

$("input").blur(function() {

console.log($(this).attr('id'));

});
  • Valeu man, had already decided, take the id of elements created with this plugin is not so simple, it creates several lists through json, but thanks for the help there.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.