(spec: any)
| 273 | type2widget[w.handle_type] = w; |
| 274 | |
| 275 | export function getWidgetElement(spec: any) { |
| 276 | if (!(spec.type in type2widget)) |
| 277 | throw Error("Unknown type in getWidgetElement() :" + spec.type); |
| 278 | |
| 279 | let elem = type2widget[spec.type].get_element(spec); |
| 280 | if (elem.length != 1) |
| 281 | elem = $(document.createElement('div')).append(elem); |
| 282 | |
| 283 | if (spec.style) { |
| 284 | // add style attribute |
| 285 | let old_style = elem.attr('style') || ''; |
| 286 | elem.attr({"style": old_style + ';' + spec.style}); |
| 287 | } |
| 288 | if (spec.click_callback_id) { |
| 289 | elem.on('click', (e) => { |
| 290 | pushData(null, spec.click_callback_id); |
| 291 | }); |
| 292 | elem.addClass('pywebio-clickable'); |
| 293 | } |
| 294 | if (spec.container_dom_id) { |
| 295 | if (spec.container_selector) |
| 296 | elem.find(spec.container_selector).attr('id', spec.container_dom_id); |
| 297 | else |
| 298 | elem.attr('id', spec.container_dom_id); |
| 299 | } |
| 300 | return elem; |
| 301 | } |
| 302 | |
| 303 | |
| 304 | export function render_tpl(tpl: string, data: { [i: string]: any }) { |
no test coverage detected
searching dependent graphs…