Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Sencha User
    Join Date
    Apr 2013
    Posts
    6
    Vote Rating
    0
    bailz is on a distinguished road

      0  

    Default Firing function from external JS file

    Firing function from external JS file


    Hello all,

    Hopefully you can help. I have loaded an external JS resource into my Sencha Architect project and am looking for the correct code to fire a function from the external JS file.

    How could I fire the following function from a button in Sencha Architect? I am looking to fire the function from something like:

    Code:
    <button onclick="myFunction()">Try it</button>
    

    The external JS file contains:

    Code:
    function myFunction()
    {
    alert("Hello World!");
    }
    

  2. #2
    Ext JS Premium Member tangix's Avatar
    Join Date
    Mar 2010
    Location
    Stockholm, Sweden
    Posts
    520
    Vote Rating
    50
    tangix is a jewel in the rough tangix is a jewel in the rough tangix is a jewel in the rough

      0  

    Default


    I strongly suggest reading up on the MVC approach that is recommended by projects in Sencha and is the way you are supposed to structure a project in Sencha Architect. A MVC approach will also ensure that your project will grow graceful.
    See http://docs.sencha.com/extjs/4.2.0/#...n_architecture

    To answer your direct question, here's one way to do it in Sencha Architect:
    http://screencast.com/t/3eUd9XRrZ

    The steps shown in the screencast:
    1. Inside of the project directory, create a resources directory and place the hello.js external file there.
    2. Create a new Ext JS 4.2.x project in Sencha Architect.
    3. Create a Panel and add a Button to the Panel.
    4. Save the project into the directory where the resources directory from step 1 was created, I call it hello_click
    5. Add a JS Resource in Sencha Architect. Set the url property to resources/hello.js. Switch to Code view to make sure the file is loaded properly.
    6. Set userAlias of the Panel to "mypanel", this to make it possible to reference from the Controller
    7. Add a Controller to the project and add a function init - see the docs http://docs.sencha.com/extjs/4.2.0/#...app.Controller Add a standard "this.control" structure in Controller's init() function:
    Code:
    this.control({
        'mypanel button': {
            click: hello
        }
    });
    This will detect the event "click" from a Button inside de mypanel Panel and execute the function hello().
    See more: http://docs.sencha.com/extjs/4.2.0/#...method-control

    8. Save the project and load it in a browser.

    There are other ways to do this (without a Controller, directly handling the click event in the Button for example), but to really benefit from Ext JS 4.2 and Sencha Architect I strongly suggest using MVC structure of your projects.

    Happy coding!
    /Mattias

  3. #3
    Sencha User
    Join Date
    Apr 2013
    Posts
    6
    Vote Rating
    0
    bailz is on a distinguished road

      0  

    Default


    Thank you Mattias,

    I really appreciate your time on this, and yes my example code really has nothing to do with MVC coding standards.

    I guess I asked in the wrong context. I was after a hello world example using a button in Sencha Architect firing a function contained within an external JS resource. Your example has helped me a long way, thank you.

    The example code I used was from JQuery mobile, and I am slowly learning the MVC coding approach used in Sencha Architect. In fact Architect has been both a godsend and a trial in patience as it is forcing me to change from my old spaghetti coding standards.

  4. #4
    Ext JS Premium Member tangix's Avatar
    Join Date
    Mar 2010
    Location
    Stockholm, Sweden
    Posts
    520
    Vote Rating
    50
    tangix is a jewel in the rough tangix is a jewel in the rough tangix is a jewel in the rough

      1  

    Default


    Glad to hear.
    JavaScript really supports writing spagetthi-style code and the MVC approach takes a sane start. Just completed a major rewrite of an old Ext JS 3.x project with big-time spagetthi and migrated it to a MVC approach. Around 25 Models, 45 Views and 15 Controller in total - would have been an absolute nightmare without MVC.
    The result was a well-structured project that is easy to maintain and possible to run through Sencha Cmd to produce a monolithic single-file build of your entire project and to put it in production in an efficient way.

    Best of luck with your projects,
    /Mattias

  5. #5
    Sencha User
    Join Date
    Apr 2013
    Posts
    6
    Vote Rating
    0
    bailz is on a distinguished road

      0  

    Default


    Yes I am really excited learning Architect, in fact I started out with Sencha a few weeks ago by using just the Sencha Touch SDK and Sencha CMD to build the projects. My spaghetti coding quickly got out of hand using the SDK directly.

    I then realised that Sencha Architect forces me into a proper MVC approach (i.e it basically won't allow you to spaghetti code and every option I need can be found on the right hand panel in Architect). I am convinced MVC beginners like myself need to start with Sencha Architect first, then worry about hand coding in the Sencha Touch SDK at a far later point.

    Even though the concept you have posted might seem extremely basic and trivial to most Sencha veterans, I am finding that they connect your mind with how proper MVC coding is approached and executed in the browser.

  6. #6
    Ext JS Premium Member tangix's Avatar
    Join Date
    Mar 2010
    Location
    Stockholm, Sweden
    Posts
    520
    Vote Rating
    50
    tangix is a jewel in the rough tangix is a jewel in the rough tangix is a jewel in the rough

      0  

    Default


    As you are planning to use Sencha Touch I can strongly recommend the first lectures of Stanford's "iPad and iPhone Application Development" (https://itunes.apple.com/us/itunes-u...nt/id473757255). They first lectures covers much of the basics of MVC and you will find striking similarities between iOS and Sencha Touch in how the MVC is approached. Of course the syntax is totally different, but try to focus on the concepts and you should have a head start at Sencha Touch.

    Sorry - wrong link, should the be the Fall 2011 course as the 5.0 SDK is more similar to Sencha Touch:
    https://itunes.apple.com/us/itunes-u...nt/id473757255

  7. #7
    Sencha User
    Join Date
    Apr 2013
    Posts
    6
    Vote Rating
    0
    bailz is on a distinguished road

      0  

    Default


    Thanks Mattias, I will have a look.

  8. #8
    Sencha User
    Join Date
    Jan 2014
    Location
    pittsburg , PA
    Posts
    32
    Vote Rating
    0
    arunmatics is on a distinguished road

      0  

    Default


    Hi ,

    I have a Ext.onReady(function() {} from main.js. and i have one table with column using grid.panel from another .js file.

    How can i call the second .js file in main.js file ?

    Thanks,
    Santhosh

Thread Participants: 2