javascript - Rendering ExtJS 4+ MVC application in a html div - how-to? -
all examples have found far explain how render extjs (4.2) mvc application within "viewport", in other words means full browser screen, , occupying whole html body.
i render application within existing html page within named div, can have html design around application.
<div id="appdiv"><!-- application runs here --></div> i've seen sites extjs 4 examples use trick render extjs app within page using iframe.
is possible avoid iframe? and, if is, how skeleton of extjs 4.2 application shall if rendered within div.
notes: in extjs 3 have found solution creating panel main container renders within named div. however, version 4.2 (and possibly earlier 4.x's) suggests mvc application approach seem far superior.
---- edits
i have realised have put starting points question.
- source example generated extjs's cmd command generates "application" framework skeleton.
- skeleton of application consisted of many files including engine reference, , other references, not able include here sources in "application" dir/folder. skeleton of application can done using cmd in fashion:
sencha -sdk /myuserroot/sencha/cmd/3.1.1.274 generate app extgenapp /mywebroot/htdocs/extja_genappgenerates files , folders , copies necessary files in place. - "user" activity area in "app" dir. app dir has subdirs views, controllers, models , additional stuff.
- as in many other frameworks expected keep folder structure framework can find appropriate files , initialise them.
- list of files:
index.html (in root of generated application)
<!doctype html> <html> <head> <meta charset="utf-8"> <title>extgenapp</title> <!-- <x-compile> --> <!-- <x-bootstrap> --> <link rel="stylesheet" href="bootstrap.css"> <script src="ext/ext-dev.js"></script> <script src="bootstrap.js"></script> <!-- </x-bootstrap> --> <script src="app/app.js"></script> <!-- </x-compile> --> </head> <body> <h1>html before</h1> <div id="appbox"></div> <h1>html after</h1> </body> </html> app/app.js
/* file generated , updated sencha cmd. can edit file needed application, these edits have merged sencha cmd when performs code generation tasks such generating new models, controllers or views , when running "sencha app upgrade". ideally changes file limited , work done in other places (such controllers). if sencha cmd cannot merge changes , generated code, produce "merge conflict" need resolve manually. */ // not delete - directive required sencha cmd packages work. //@require @packageoverrides ext.application({ name: 'extgenapp', views: [ 'main', 'appboxview' ], controllers: [ 'main' ], launch: function() { new ext.view.appboxview({ renderto: 'appbox' });; // generates error } }); note: there no launch function there auto generate viewport (one gets default generator)
app/controller/main.js
ext.define('extgenapp.controller.main', { extend: 'ext.app.controller' }); app/view/appboxview.js
ext.define('extgenapp.view.appboxview', { extend: 'ext.panel.panel', requires:[ 'ext.tab.panel', 'ext.layout.container.border' ], layout: { type: 'border' }, items: [{ region: 'west', xtype: 'panel', title: 'west', width: 150 },{ region: 'center', xtype: 'tabpanel', items:[{ title: 'center tab 1' }] }] }); this shall initial layout on screen (afaik)
and finally:
app/view/main.js
ext.define("extgenapp.view.main", { extend: 'ext.component', html: 'hello, world!!' }); which shall, understood, "content".
as is, generates error of not founding "ext.view.appboxview" , how looks me, framework not initialise application.
a viewport specialized ext.container.container auto sizes the document body.
as such, can create own in launch method:
launch: function(){ new mycontainer({ renderto: 'mydiv' }); }
Comments
Post a Comment