MCPcopy Index your code
hub / github.com/pywebio/PyWebIO / create_element

Method create_element

webiojs/src/models/input/select.ts:35–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33 }
34
35 create_element(): JQuery {
36 let spec = deep_copy(this.spec);
37 const id_name = spec.name + '-' + Math.floor(Math.random() * Math.floor(9999));
38 spec['id_name'] = id_name;
39
40 let html = Mustache.render(select_input_tpl, spec);
41 this.element = $(html);
42 this.setup_select_options(this.element, spec.options);
43
44 if (this.use_bootstrap_select) {
45 // @ts-ignore
46 this.element.find('select').selectpicker();
47 }
48
49 if (spec.onblur) {
50 // blur事件时,发送当前值到服务器
51 this.element.find('select').on("blur", (e) => {
52 this.on_input_event("blur", this);
53 });
54 }
55 if (spec.onchange) {
56 this.element.find('select').on("change", (e) => {
57 this.on_input_event("change", this);
58 });
59 }
60 return this.element;
61 }
62
63 setup_select_options(elem: JQuery, options: any) {
64 let input_elem = elem.find('select');

Callers

nothing calls this directly

Calls 3

setup_select_optionsMethod · 0.95
deep_copyFunction · 0.90
$Function · 0.50

Tested by

no test coverage detected