extjs - Linking images to different views -
i link images different views. have searched sencha docs , videos can't resolve issue. myapp application contains 3 views: main, home, setting, firstpage 1 controller: maincontroller want link first image home(view) firstpage(view)
app.js
ext.loader.setpath({ 'ext': 'touch/src', 'myapp': 'app' }); viewport: { layout: { type: 'card', animation: { type: 'fade', direction: 'left', duration: 300 } } } //</debug> ext.application({ name: 'myapp', requires: [ 'ext.messagebox' ], views: [ 'main', 'home', 'setting','firstpage' ], controllers: [ 'maincontroller' ], icon: { '57': 'resources/icons/icon.png', '72': 'resources/icons/icon~ipad.png', '114': 'resources/icons/icon@2x.png', '144': 'resources/icons/icon~ipad@2x.png' }, isiconprecomposed: true, startupimage: { '320x460': 'resources/startup/320x460.jpg', '640x920': 'resources/startup/640x920.png', '768x1004': 'resources/startup/768x1004.png', '748x1024': 'resources/startup/748x1024.png', '1536x2008': 'resources/startup/1536x2008.png', '1496x2048': 'resources/startup/1496x2048.png' }, launch: function() { // destroy #apploadingindicator element ext.fly('apploadingindicator').destroy(); // initialize main view ext.viewport.add(ext.create('myapp.view.home')); }, onupdated: function() { ext.msg.confirm( "application update", "this application has been updated latest version. reload now?", function(buttonid) { if (buttonid === 'yes') { window.location.reload(); } } ); } }); maincontroller.js
ext.define('myapp.controler.maincontroller', { extend: 'ext.app.controller', xtype: 'controllerpanel', refs : { homecontroller : 'firstdiv', }, views : [ 'home', 'firstpage' ], config: { control: { '#firstdiv': { // on tap event, call onnewtap tap: 'onfirstimagetap' } } }, launch: function() { // when our controller launched, create instance of our user view , add viewport // has card layout ext.viewport.add(ext.create('myapp.view.home')); }, onfirstimagetap: function() { // when user taps on button, create new reference of our new view, , set active // item of ext.viewport ext.viewport.setactiveitem(ext.create('myapp.view.firstpage')); } }); main.js (view)
ext.define('myapp.view.main', { extend: 'ext.container', config: { items: [ { xtype: 'homecontainer' }, { xtype: 'settingcontainer' }, { xtype: 'firstcontainer' } ] } }); home.js
ext.define('myapp.view.home', { extend: 'ext.container', xtype: 'homecontainer', config: { title: 'home', cls: 'maincss', html: [ '<div id=firstdiv>', '<img src="resources/images/1.jpg" height="25%" width="25%" />', '</div>', '<img src="resources/images/2.jpg" height="25%" width="50%" />', '<img src="resources/images/3.jpg" height="25%" width="25%" />', '<img src="resources/images/4.jpg" height="25%" width="25%" />', '<img src="resources/images/5.jpg" height="25%" width="25%" />', '<img src="resources/images/6.jpg" height="25%" width="50%" />', '<img src="resources/images/7.jpg" height="50%" width="25%"/>', '<img src="resources/images/8.jpg" height="25%" width="25%" />', '<img src="resources/images/9.jpg" height="25%" width="25%"/>', '<img src="resources/images/10.jpg" height="25%" width="25%"/>', '<img src="resources/images/11.jpg" height="25%" width="25%"/>', '<img src="resources/images/12.jpg" height="25%" width="50%"/>', ].join("") } }); firstpage.js
ext.define('myapp.view.firstpage', { extend: 'ext.container', xtype: 'firstcontainer', cls: 'setting', config: { title: 'setting', iconcls: 'settings', html: [ 'first page', ].join("") } }); setting.js
ext.define('myapp.view.setting', { extend: 'ext.container', xtype: 'settingcontainer', cls: 'setting', config: { title: 'setting', html: [ 'setting page', ].join("") } });
this code might give idea.
ext.define('myapp.view.home', { extend: 'ext.container', xtype: 'homecontainer', config: { title: 'home', cls: 'maincss', html: [ '<div id=firstdiv>', '<img src="resources/images/1.jpg" height="25%" width="25%"/>', '</div>', '<img src="resources/images/2.jpg" height="25%" width="50%" />', '<img src="resources/images/3.jpg" height="25%" width="25%" />', '<img src="resources/images/4.jpg" height="25%" width="25%" />', '<img src="resources/images/5.jpg" height="25%" width="25%" />', '<img src="resources/images/6.jpg" height="25%" width="50%" />', '<img src="resources/images/7.jpg" height="50%" width="25%"/>', '<img src="resources/images/8.jpg" height="25%" width="25%" />', '<img src="resources/images/9.jpg" height="25%" width="25%"/>', '<img src="resources/images/10.jpg" height="25%" width="25%"/>', '<img src="resources/images/11.jpg" height="25%" width="25%"/>', '<img src="resources/images/12.jpg" height="25%" width="50%"/>', ].join(""), listeners: { show: function (panel) { var el = panel.element, image = el.down('#firstdiv'); image.on('tap', function (e, t) { ext.viewport.setactiveitem( ext.create('myapp.view.firstpage')); }, panel); } } } });
Comments
Post a Comment