ScriptContainer Problem

  1. #1

    ScriptContainer Problem

    Hi,

    In my code I have a javascript dependency problem. At the moment I have some code that goes like this:


    1 - Use ScriptContainer to include ExtJs/Coolite/control creation code.
    2 - Include my own script which defines some functions but makes use of Ext.


    The problem is that because I use the ScriptContainer to position the Ext includes before my own script, i also end up including the code to create my controls before i have defined functions needed by them in my own code (2).


    I understand I can have Coolite not inject the scripts for me, however, will i sufer any problems by this? The order I need is:


    1 - Include ExtJs/Coolite libraries.
    2 - Include my own script.
    3 - ExtJs control creation code


    Any help would be great.


    Thanks
  2. #2

    RE: ScriptContainer Problem

    Hi,

    May be I misunderstood you or I don't have enough detais about your script but ExtJS controls will be created after loading all js files. Therefore if you include own scripts after ExtJS control creation block it will the same as add scripts before that block (because that block use Ext.onReady)


    <div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-weight: inherit; font-style: inherit; font-size: 12px; font-family: inherit; vertical-align: baseline; color: rgb(51, 51, 51); ">1 - Include ExtJs/Coolite libraries. | | 1 - Include ExtJs/Coolite libraries.
    <div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-weight: inherit; font-style: inherit; font-size: 12px; font-family: inherit; vertical-align: baseline; color: rgb(51, 51, 51); ">2 - Include my own script. | the same| 2 - ExtJs control creation code
    <div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; outline-width: 0px; outline-style: initial; outline-color: initial; font-weight: inherit; font-style: inherit; font-size: 12px; font-family: inherit; vertical-align: baseline; color: rgb(51, 51, 51); ">3 - ExtJs control creation code | effect | 3 - Include my own script.

  3. #3

    RE: ScriptContainer Problem

    Thanks for replying, I will try and clarify myself hopefully:

    If i use a ScriptContainer to include the Ext library (1) before I make use of it in my own code (2) then it also includes the Ext code that creates my controls at point (1) however, my coolite/ext controls make use of code defined in (2). Because (1) comes before (2) my coolite/ext controls attempt to make use of an undefined JS function (via Listener handlers) which causes errors in firebug and the application wont render properly.


    What I need to do is include the Ext library (1), then my own code (2), and then have the coolite engine inject the code for creating the ext controls (3) which make use of my own code (2).
  4. #4

    RE: ScriptContainer Problem

    Hi,

    Please post simple example which reproduces the problem. We will try to solve it
  5. #5

    RE: ScriptContainer Problem

    Sure, its a big project I'm working on so i'll try and cut something that will illustrate it:

    This is part of my aspx page:


    
    
    <head runat="server">
        <title>Page</title>
    
    
        <ext:ScriptContainer runat="server"></ext:ScriptContainer>
    
    
        <script type="text/javascript" src="../../Scripts/CFRMIS.Domestic.js" />
    </head>
    
    
    
    ...
    
    
    <ext:ToolbarButton ID="btnAdd" runat="server" Text="Create New Premise" Icon="Add">
      <Listeners>
        <Click Fn="newPremise" />
      </Listeners>
    </ext:ToolbarButton>
    
    
    
    ...

    CFRMIS.Domestic.js has this in it:


    
    
            var newPremise = function() {
            	// Does Things that use Ext such as Ext.Msg.show();
            }

    So you can see that my .js file needs the Ext include to come before it but using the ScriptContainer to do this puts my code to create my ToolbarButton before I have declare my newPremise function and therefore Firebug isn't happy.


    Does this help?


    The solution I believe is to include ExtJS, then my script, then to have coolite inject the control creation code. However, I can't do this with the ScriptContainer and would have to include ExtJS myself using standard <script> blocks. Will I lose any benefits of coolite doing this for me though?
  6. #6

    RE: ScriptContainer Problem

    Hi,

    Thanks for example. We will investigate it.
    Just possible quick workaround. Try to use Handler instead Fn


    <Click Handler="newPremise();" />
  7. #7

    RE: ScriptContainer Problem

    I can confirm that code does work and would probably be a valid workaround.

Similar Threads

  1. [1.0] ScriptContainer
    By methode in forum Open Discussions
    Replies: 2
    Last Post: Apr 07, 2010, 7:15 AM
  2. Replies: 0
    Last Post: Sep 25, 2009, 11:17 AM
  3. Replies: 2
    Last Post: Jun 10, 2009, 5:27 AM
  4. [CLOSED] ScriptContainer
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Aug 18, 2008, 6:38 PM

Posting Permissions