Получить элемент в window по классу
Здравствуйте. Задача:
Есть элемент widget.inspector, наследующий Window. У него есть кнопка xtype: 'buttongroup' и элемент iframe. Необходимо в обработчике щелчка по кнопке получить объект iframe для изменения его свойства src. У iframe есть только свойство class, id у него нет. Очень прошу помочь. |
var result = inspector.getEl().select("iframe"); var iframe = result.elements[0]; iframe.set({src: "newsrc"}); http://docs.sencha.com/ext-js/4-1/#!...-method-select http://docs.sencha.com/ext-js/4-1/#!...ent-method-set http://docs.sencha.com/ext-js/4-1/#!...mpositeElement |
Что-то вы по ходу меняете задачу))))
|
Если iframe один, то должно сработать.
|
А как получить объект inspector? this и event ссылаются на объект button.
|
Цитата:
|
this.up() : [Exception: TypeError: Object [object Object] has no method 'up']
|
Раз так, то приводите весь код.
|
Inspector.Controller:
Ext.define('AM.controller.Inspector',{ extend: 'Ext.app.Controller', views: ['inspector'], init: function(options){ this.control({ 'inspector button[action=goto]':{click: this.gotoPage, delegate: this}, 'inspector button[action=inspect]':{click: this.inspect}, 'inspector': {id: options.id, destroy: this.closeWin, move: this.saveWin} }) }, //открыть страницу gotoPage: function(event){ var url = Ext.getCmp('url').getValue(); if(!/^http:\/\//.test(url)){ url = 'http://'+url; //url = 'http://interface/index.php?controller=content&action=getHttp&addres s='+aurl; } var iframe = Ext.get('.container'); iframe.dom.src = url; Ext.getCmp('url').setValue(url); this.win.setTitle(url); } ... Inspector.view: Ext.define('AM.view.inspector', { extend: 'Ext.window.Window', alias: 'widget.inspector', initComponent: function(options){ var toolbar = new Ext.Toolbar({ defaults:{ iconAlign: 'top' }, items: [ {text:'Назад',iconCls:'back', action: 'back'}, {text:'Вперед',iconCls:'forward'}, {text:'Обновить',iconCls:'reload'}, {text:'Остановить',iconCls:'stop'}, {text:'Домой',iconCls:'home', action: 'goHome'}, '-', { xtype: 'buttongroup', items:[ {xtype:'textfield',id:'url',width:250,enableKeyEve nts:true}, {iconCls:'goto', action: 'goto'} ] }, {text: 'Инспектировать', action: 'inspect'}, '->', {text:'Закладки',iconCls:'book'} ] }); if(this.idl) this.id = this.idl; var url = this.url == null ? '' : this.url; //this.height= 400; //this.width= 600; //this.x= 450; //this.y= 250; this.title= 'Инспектор'; this.tbar = toolbar; this.closable= true; this.maximizable= true; this.maskDisabled= true; this.plain= true; this.layout= 'fit'; this.bodyStyle= 'background-color:#fff'; //this.html= '<iframe id="container" src="" style="width:100%;height:100%;border:none"></iframe>'; this.items=[{ xtype : "component", autoEl : { tag : "iframe", src : url, cls: 'container' }, listeners: { afterrender: function () { this.getEl().on('load', function () { //console.log('loaded'); }); } } }]; this.callParent(arguments); } }) |
Кнопка с action='goto' и соответствующий обработчик в контроллере
|
Часовой пояс GMT +3, время: 15:43. |