-
5 Aug 2012 11:54 PM #1
Different behavior between development and build - View - Ajax - initialize
Different behavior between development and build - View - Ajax - initialize
Hey!
I am not sure, if it would be better to report this in different thread and I also think, the view/ajax-part may be caused by my source, but because sencha behaves the way I don't expect, I will only start this thread at first:
1)
My code is fully functional when developing. Everything works fine: Main is started, this starts Frame, initialize is called, html is loaded an successfully updated.
2)
When building with 'package'-parameter the initialize-function is not called, so there is no html loaded.
3)
When using 'production', the first call gives the same result like 2). The 2nd problem occurs:
- I do some changes (i.e. changing the initial html)
- build again
- first refresh
- the app asks me to reload itself
- app reloads an logs into the console:
- second, third, n-th refresh:Malformed delta content received for http://localhost/app.js http://localhost/:56
G http://localhost/:56
(anonymous function) http://localhost/:59
h.onreadystatechange http://localhost/:54
- console logs something like
The 'unexpected token' changes from time to time.error evaluating http://localhost/app.js with message: SyntaxError: Unexpected token ; http://localhost/:56
G http://localhost/:56
c http://localhost/:57
b http://localhost/:57
...
I found this many time in different forums, but I never read an answer. And just to be sure:
The code works fine when in development, so there must be something with generated code / caching mechanism.
Questions:
- Why is the initialize-function not called when using the build. What did I miss?
- What's wrong with the generated delta / caching?
Here is my code:
Main:
Frame:Code:Ext.define('EBook.view.Main', { extend: 'Ext.Container', requires: 'Ext.carousel.Carousel', config: { layout: 'fit', fullscreen: true, cls: 'main', items: [ { xtype: 'carousel', items: [ { title: 'FRAME', xtype: 'frame', cls: 'card' } ] } ] } });
Code:Ext.define("EBook.view.Frame", { extend: "Ext.Container", requires: [ "Ext.Ajax", "Ext.Img" ], alias: "widget.frame", autoCreate: true, config: { layout: { type: 'vbox', }, items: [ { xtype: 'panel', layout: 'hbox', cls: 'card-header', items: [ { xtype: 'panel', html: 'ShowMe.htm', cls: 'card-titel' } ] }, { xtype: 'panel', cls: 'card-content style_3', html: 'initial html...', flex: 1, height: 938, scrollable: 'vertical', initialize: function () { console.log('initialize'); this.setHtml("static content via this.setHtml()"); Ext.Ajax.request({ scope: this, url: './resources/showme.htm', success: function ( response ) { console.log('success'); console.log(response); this.setHtml(response.responseText); }, failure: function ( response ) { console.log('failure'); console.log(response); this.setHtml("error: " + response.status); } }); } } ] } });
-
6 Aug 2012 1:08 AM #2
OK. Two days of testing, editing, probing, hoping, crying and more whatever-ing and an hour after posting, I see it:
The way I defined the Frame-view, the initialize-function seems to be part of the items config-block. I defined an other directly as part of Frame an it is called in the build.
Questions have changed a bit:
1. Why does the build behave other than the development (why does it even work?!).
2. What problems does the delta-cache-mechanism have with this kind of config?
3. Is there a way to pass the initialize-function to the child item? I would like to save an own class-file.
---
With using an extra file for the frame-html-item, initialize is called, but I still can't run with 'production' generated deltas!
-
6 Aug 2012 5:47 AM #3Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 436
It is not recommended to override methods like that anyway. If you need to do that, create a new class.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
6 Aug 2012 11:24 PM #4
Sorry, but....
Sorry, but....
....please don't take this personal, but...
... I saw a lot of answers written by you, which really missed the target. That was, why I wrote exactly this:
The 'right' Sencha-way is the one thing, the other is, that there is a different behavior between executing the development-sources and the build sources. That was the first point.I found this many time in different forums, but I never read an answer. And just to be sure:
The code works fine when in development, so there must be something with generated code / caching mechanism.
The second is, that there is still a problem with the delta-builds and I found that error very often. Maybe, this is because of fault like I did, but this shows only, that point 1 is more important.
Point 3)
What means ' not recommended'? Is there a way to do that (without an own class-file) or is it still not possible?
---
This Thread was started in the bug-subforum because of the points 1 and 2 (and I tried to explain that in the first post).
If these point are really [Closed] in Sencha opinion, than this is a reason to not use sencha in our company. That kind of behavior costs a lot of developers time.
Please don't missunderstand me. I believe, that you read a very lot of bug, questions etc every day and therefor have to tally them fast and I can understand this. But from my point of view, you underestimate, what it means to develop a running app without being able to build it and without having a chance to debug it.
-
7 Aug 2012 4:59 AM #5Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 436
If you need to override the initialize method, then you need to create your own class. It is not recommended nor valid as a config, the initialize method is not a config.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
7 Aug 2012 5:57 AM #6
OK, so it is not possible, that makes sense.... understood.
I hope you recognized the two things that I reported as some kind of bug.
Thx
Looks like we can't reproduce the issue or there's a problem in the test case provided.


Reply With Quote