()
| 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'); |
nothing calls this directly
no test coverage detected