Closed glennswest closed 7 years ago
I do it using a decorator...same for color! (u look to have same need than I :) )
Its giving me pain:
Here is the upper level:
<!DOCTYPE html>
Here is the code that should add in the calendar: function mddecorate(element,schema) { name = element.tagName; switch(name){ case "INPUT": gsw = element; fieldname = element.placeholder.toLowerCase(); // element.id = BrutusinForms#0_0 if ('format' in schema){ switch(schema.format){ case "date": console.log(schema); console.log(schema.$id); console.log(element.id); var theid; // "input[id$=txtDatepicker]" theid = '#' + element.id; console.log(theid); $(theid).datepicker({dateFormat: 'yy-mm-dd'}); break; } } break; } }
Console output:Navigated to http://ctl.ncc9.com:9093/view/devices/new mddecorate.js:15 Object {type: "string", format: "date", description: "DateCreated", $id: "$.date_created"} mddecorate.js:16 $.date_created mddecorate.js:17 BrutusinForms#0_1 mddecorate.js:21 #BrutusinForms#0_1
Never see the datepicker. :(
What Im I missing
Wow, its easy:
function mddecorate(element,schema) { name = element.tagName; switch(name){ case "INPUT": gsw = element; fieldname = element.placeholder.toLowerCase(); // element.id = BrutusinForms#0_0 if ('format' in schema){ switch(schema.format){ case "date": $(element).datepicker(); break; } } break; } }
For more readable version: https://github.com/glennswest/microdash/blob/065e6983a0f8b77a90d5061959c9a216ac343bce/public/mddecorate.js
Thanks for the help. Figured it out by reading brutusin/json-forms code, reading others code is the best way to learn.
I'm late here, glad to see you figured it out
Is there a way of getting json-forms to use a datepicker? Thinking also I might want to also use a picker for a table as well, for joined tables.