PDA

View Full Version : Accessing files in custom folder on fiddle.sencha.com



raulkaj
18 Jun 2015, 5:32 AM
I am trying to create an application on sencha fiddle. I have created 2 folders app1 and app2. And trying to access app1.js and app2.js in that folder. But i am not able to access them.
Following is the link to the application

ou3

mitchellsimoens
18 Jun 2015, 6:02 AM
First off, what you are trying to do is not really supported in Ext JS. A single page should only have a single application. That application can instantiate classes (controllers, views, etc) from namespaces outside itself but there should only be one application.

As for fiddle, this depends on how the files are split out in the resulting HTML. When you create files in fiddle, they aren't really files, they are just displayed in a tree format to allow some organization and demonstration purposes. Each "file" is inserted inline into the HTML into a <script> tag.

So if you have 4 files: app.js, foo.js, bar.js and baz.js they will be inserted as such:


<script type="text/javascript">
Ext.onReady(function() {
//source code for foo.js
});
Ext.onReady(function() {
//source code for bar.js
});
Ext.onReady(function() {
//source code for baz.js
});
Ext.onReady(function() {
//source code for app.js
});
</script>

Couple things to notice:


Each "file" is wrapped with Ext.onReady. Reason for the wrapping of Ext.onReady is we didn't want to always force people to use Ext.application or the like. So you can have a file where it simply creates a component, nothing else.
Each "file" is inserted inline into the <script>
app.js file will always be last.
The order is not managed other than the app.js being last. The order is what you see in the tree panel. There is no requires or any other dependency order management. Reason for this, fiddle isn't built to host whole applications, it's built as a test case and example collector.