Results 1 to 3 of 3

Thread: How to add event handler for dynamically created widgets in the controller?

  1. #1
    Sencha Premium Member
    Join Date
    Oct 2012
    Location
    New Delhi, INDIA
    Posts
    60
    Vote Rating
    1
      0  

    Default How to add event handler for dynamically created widgets in the controller?

    Hello Forum members,

    I'm a newbie to ExtJs world. I started implementing a MVC based ExtJs 4 project. My problem is -
    I have a view(myview.js) which contains a button. Whenever I click on that button (mycontroller.js) I'll create a new window which pops up on the parent window. This new window contains a button and now I need to handle click event for this button. How can I do it? Where should I write the event handler? I tried to do it in mycontroller.js itself. But it's not working as the window is getting created in the runtime. Can someone help me regarding this please?

    Thanks a lot

  2. #2
    Sencha User Tim Toady's Avatar
    Join Date
    Feb 2010
    Location
    Pennsylvania
    Posts
    603
    Vote Rating
    284
      2  

    Default

    It shouldn't matter that the window gets created later. If the window has an itemId or alias you can target it pretty easily. In your this.control call in your controller you can use a selector like
    '#itemId button[text="Cancel"]'

    Of course if you changed your button text then it wouldn't work, so you might want to target it differently. I try not to go too crazy with itemIds, but they are preferable to ids when you need to use something like that.

  3. #3
    Sencha User
    Join Date
    Oct 2012
    Posts
    3
    Vote Rating
    0
      0  

    Default hehe

    thanks a lot, you have just resolved my problem...

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •