Hi, I am still learning metawidgets. I have a situation where I need to disable or enable 'href' and a 'button' based on data that is populated in a widget created using metawidgets. So, I already have an inspectionresultprocessor which reads a property file and renders the widgets native to Javascipt UI framework. I am unable to associate further rules that are dependent on the populated data. So, for example, if username is X, then enable edit else disable. Please help me with this.
Thanks in advance.
Shivali
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for the example. It really helped. I have a related question. In the example, the property used is disabledUnless. Is 'disabledUnless' a special attribute/property like 'hidden' or is it something that was just defined in the js file for the example. Also, where can we find the complete list of property attributes (like 'hidden') in the documentation?
Thanks,
Shivali
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It was defined in the js file for the example. All the code you need is in the example. You can see it is injected by the Inspector, and handled by the WidgetProcessor (a few lines below).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I see. Thanks a lot for your prompt responses. It really helps a lot.
I have couple of more queries:
i) Is it possible to inspect two objects together and then buildwidgets.
For example, in showDialog method in contacts.js in Addressbook example, the object is given in the path as mw.setAttribute( 'path', 'addressbook.current' ); Here, how do we add another object such that the widgets from first one are readonly while second one are editable?
ii) How do we specify properties on nested attributes? For example, in the following JSON, if I have to hide ipAddress widget, how should I specify in JsonSchemaInspector?
{
"data":[ {
"machines":{
"ipAddress": "90.12.23.15",
"shortName": "abc"
},
"timezone": "America/New_York"
}]
}
I did try a few things but they did not seem to work...
Thanks a ton!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The idea here is you would use multiple Metawidgets on a page, either side-by-side or embedded within each other. Metawidgets are very lightweight (they can all share the same config objects). You can use lots together.
JsonSchemaInspector supports this automatically. It will be something like (note the items/properties convention, as defined by the JSON Schema specification):
Hi,
What would be a good way of adding custom validations on inputs that are added in a form created using metawidgets for Javascript? For example, if I want to check if a number falls in range, or if an email id is in the correct format, how should I add these? Also, I have seen some plugins for JqueryValidator https://jqueryvalidation.org , how could we use such plugins for metawidgets?
Thanks,
Shivali
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I am still learning metawidgets. I have a situation where I need to disable or enable 'href' and a 'button' based on data that is populated in a widget created using metawidgets. So, I already have an inspectionresultprocessor which reads a property file and renders the widgets native to Javascipt UI framework. I am unable to associate further rules that are dependent on the populated data. So, for example, if username is X, then enable edit else disable. Please help me with this.
Thanks in advance.
Shivali
Blogged a complete example for you here: http://blog.kennardconsulting.com/2016/05/metawidget-associating-eventlisteners.html
Thanks for the example. It really helped. I have a related question. In the example, the property used is disabledUnless. Is 'disabledUnless' a special attribute/property like 'hidden' or is it something that was just defined in the js file for the example. Also, where can we find the complete list of property attributes (like 'hidden') in the documentation?
Thanks,
Shivali
It was defined in the js file for the example. All the code you need is in the example. You can see it is injected by the Inspector, and handled by the WidgetProcessor (a few lines below).
I see. Thanks a lot for your prompt responses. It really helps a lot.
I have couple of more queries:
i) Is it possible to inspect two objects together and then buildwidgets.
For example, in showDialog method in contacts.js in Addressbook example, the object is given in the path as mw.setAttribute( 'path', 'addressbook.current' ); Here, how do we add another object such that the widgets from first one are readonly while second one are editable?
ii) How do we specify properties on nested attributes? For example, in the following JSON, if I have to hide ipAddress widget, how should I specify in JsonSchemaInspector?
{
"data":[ {
"machines":{
"ipAddress": "90.12.23.15",
"shortName": "abc"
},
"timezone": "America/New_York"
}]
}
I did try a few things but they did not seem to work...
Thanks a ton!
The idea here is you would use multiple Metawidgets on a page, either side-by-side or embedded within each other. Metawidgets are very lightweight (they can all share the same config objects). You can use lots together.
JsonSchemaInspector supports this automatically. It will be something like (note the items/properties convention, as defined by the JSON Schema specification):
Okay. I understand. Thanks a lot.
Hi,
What would be a good way of adding custom validations on inputs that are added in a form created using metawidgets for Javascript? For example, if I want to check if a number falls in range, or if an email id is in the correct format, how should I add these? Also, I have seen some plugins for JqueryValidator https://jqueryvalidation.org , how could we use such plugins for metawidgets?
Thanks,
Shivali
Can you please create a new forum post for each new topic? It helps people who are searching for similar questions.
Anyway, this should answer your question: http://blog.kennardconsulting.com/2016/05/metawidget-associating-eventlisteners.html (but instead of adding EventListeners, you would attach a validator).