This commit is contained in:
yumoqing 2024-02-28 14:11:42 +08:00
parent 638e629cf1
commit e1cf723dee
2 changed files with 6 additions and 7 deletions

View File

@ -90,8 +90,8 @@ bricks.widgetBuild = async function(desc, widget){
console.log('widgetBuild():',desc.widgettype, 'not registered', bricks.Factory.widgets_kw); console.log('widgetBuild():',desc.widgettype, 'not registered', bricks.Factory.widgets_kw);
return null; return null;
} }
desc.options.baseURI = base_url;
var options = desc.options || {}; var options = desc.options || {};
options.baseURI = base_url;
let w = new klass(options); let w = new klass(options);
if (desc.id){ if (desc.id){
w.set_id(desc.id); w.set_id(desc.id);

View File

@ -7,17 +7,16 @@ bricks.Layout = class extends bricks.JsWidget {
} }
add_widget(w, index){ add_widget(w, index){
if (! index || index>=this.children.length){ if (index >=0 && index < this.children.length){
var pos_w = this.children[index];
this.dom_element.insertBefore(w.dom_element, pos_w.dom_element);
this.children.insert(index+1, w);
} else {
// append child at end // append child at end
w.parent = this; w.parent = this;
this.children.push(w); this.children.push(w);
this.dom_element.appendChild(w.dom_element); this.dom_element.appendChild(w.dom_element);
return
} }
// insert to where index point out
var pos_w = this.children[index];
this.dom_element.insertBefore(w.dom_element, pos_w.dom_element);
this.children.insert(index+1, w);
w.dispatch('on_parent', this); w.dispatch('on_parent', this);
} }
remove_widgets_at_begin(cnt){ remove_widgets_at_begin(cnt){