MCPcopy Create free account
hub / github.com/pywebio/PyWebIO / update_input_helper

Method update_input_helper

webiojs/src/models/input/base.ts:56–81  ·  view source on GitHub ↗
(input_idx: number, attributes: { [i: string]: any })

Source from the content-addressed store, hash-verified

54 * attributes:更新值字典
55 * */
56 protected update_input_helper(input_idx: number, attributes: { [i: string]: any }) {
57 let attr2selector: { [i: string]: string } = {
58 'invalid_feedback': 'div.invalid-feedback',
59 'valid_feedback': 'div.valid-feedback',
60 'help_text': 'small.text-muted',
61 'label': '>label',
62 };
63 for (let attribute in attr2selector) {
64 if (attribute in attributes) {
65 this.element.find(attr2selector[attribute]).text(attributes[attribute]);
66 delete attributes[attribute];
67 }
68 }
69 let input_elem = this.element.find('input,select,textarea');
70 if (input_idx >= 0)
71 input_elem = input_elem.eq(input_idx);
72
73 if ('valid_status' in attributes) {
74 let class_name = attributes.valid_status ? 'is-valid' : 'is-invalid';
75 // valid_status为0/null时,表示清空valid_status标志
76 if (attributes.valid_status === 0 || attributes.valid_status === null) class_name = '';
77 input_elem.removeClass('is-valid is-invalid').addClass(class_name);
78 delete attributes.valid_status;
79 }
80 input_elem.prop(attributes);
81 }
82}
83
84

Callers 10

check_validMethod · 0.95
check_validMethod · 0.80
update_inputMethod · 0.80
update_inputMethod · 0.80
update_inputMethod · 0.80
create_elementMethod · 0.80
update_inputMethod · 0.80
update_inputMethod · 0.80
check_validMethod · 0.80
update_inputMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected