[CLOSED] Ext.onReady : Component undefined

  1. #1

    [CLOSED] Ext.onReady : Component undefined

    Previously I post a problem here and working fine with the solution .

    But now I face a problem with my bellow code ,currently I comment the onReady function ,please uncomment when you test.

    @model e.Controllers.extonready
    @{
        Layout = null;
        var x = Html.X();
    }
    
    <!DOCTYPE html>
    
    <html>
    <head>
        <meta name="viewport" content="width=device-width" />
        <title>Index</title>
        <script>
           /* Ext.onReady(function () {
                
               
                var br1 = Ext.getCmp("br1");
                var br2 = Ext.getCmp("br2");
                var br3 = Ext.getCmp("br3");
                var txt = Ext.getCmp("txt");
                if (br1.getValue() == true) {
                    txt.setValue(10);
                }
                if (br2.getValue() == true) {
                    txt.setValue(20);
                }
                if (br3.getValue() == true) {
                    txt.setValue(30);
                }
    
            })*/
          
        </script>
    </head>
        @x.ResourceManager()
    <body>
        <div>
            @x.RadioFor(m => m.br1).Listeners(l => { l.Change.Handler = "if (this.getValue() == true) {#{br2}.setValue(false);#{br3}.setValue(false);}"; })
            @x.RadioFor(m => m.br2).Listeners(l => { l.Change.Handler = "if (this.getValue() == true) {#{br1}.setValue(false);#{br3}.setValue(false);}"; })
            @x.RadioFor(m => m.br3).Listeners(l => { l.Change.Handler = "if (this.getValue() == true) {#{br1}.setValue(false);#{br2}.setValue(false);}"; })
            @x.TextField().ID("txt")
        </div>
    </body>
    </html>
    public class ExtOnReadyController : Controller
        {
            //
            // GET: /ExtOnReady/
    
            public ActionResult Index()
            {
    
                return View(extonready.returnvalue());
            }
    
        }
    
        public class extonready
        {
            public bool br1 { get; set; }
            public bool br2 { get; set; }
            public bool br3 { get; set; }
    
            public static extonready returnvalue()
            {
                extonready _extonready = new extonready();
                _extonready.br1 = true;
                _extonready.br2 = false;
                _extonready.br3 = false;
    
                return _extonready;
            }
        }
    in onReady function its through an java script undefined exception. I think when onReady function is executing at that time components not render completely , I read here
    Adds a function to be called when the DOM is ready
    is that mean all components fully render ? if yes, then why the javascript undefined exception occur ?if no,please suggest me what I will do.
    Last edited by Daniil; May 19, 2015 at 1:26 PM. Reason: [CLOSED]
  2. #2
    Hi matrixwebtech

    Try placing the JavaScript block at the end of your HTML like this

        <div>
            <ext:Radio runat="server" ID="br1">
                <Listeners>
                    <Change Handler="if (this.getValue() == true) {#{br2}.setValue(false);#{br3}.setValue(false);}" />
                </Listeners>
            </ext:Radio>
            <ext:Radio runat="server" ID="br2">
                <Listeners>
                    <Change Handler="if (this.getValue() == true) {#{br1}.setValue(false);#{br3}.setValue(false);}" />
                </Listeners>
            </ext:Radio>
            <ext:Radio runat="server" ID="br3">
                <Listeners>
                    <Change Handler="if (this.getValue() == true) {#{br1}.setValue(false);#{br2}.setValue(false);}" />
                </Listeners>
            </ext:Radio>
            <ext:TextField runat="server" ID="txt" />
        </div>
        <script>
            Ext.onReady(function () {
                var br1 = App.br1;
                var br2 = App.br2;
                var br3 = App.br3;
                var txt = App.txt;
                if (br1.getValue() == true) {
                    txt.setValue(10);
                }
                if (br2.getValue() == true) {
                    txt.setValue(20);
                }
                if (br3.getValue() == true) {
                    txt.setValue(30);
                }
    
            })
        </script>
    Also there is no need to use Ext.getCmp since the namespace App works.
  3. #3
    Hi EnZo
    thankx for reply.I also found a minute ago thats working if the script block placed at bottom of the page.this can be close.

Similar Threads

  1. Replies: 7
    Last Post: Sep 12, 2014, 4:49 PM
  2. [CLOSED] Over editor combobox component record gets undefined
    By bayoglu in forum 2.x Legacy Premium Help
    Replies: 8
    Last Post: May 06, 2013, 4:31 PM
  3. Ext.onReady,userControl and ComboBox
    By dukeucha in forum 1.x Help
    Replies: 1
    Last Post: Jun 14, 2010, 6:53 AM
  4. [CLOSED] which Ext.onReady gets executed first?
    By pkellner in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Nov 15, 2008, 3:40 PM
  5. Replies: 7
    Last Post: Nov 11, 2008, 3:59 AM

Posting Permissions