Results 1 to 6 of 6

Thread: XTemplate - functions

  1. #1
    Sencha User
    Join Date
    May 2008
    Posts
    180

    Default XTemplate - functions

    Hi,
    suppose i am having template that got:
    "<span onclick='this.myfunc()'>click me</span>"

    I want to be able to point from the template to one of my functions in the component to bind the onclick event.
    Is it possible, or the funcitions must be a global one?

    thanks

  2. #2
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    Do not do it like that.

    Add an onclick listener to the element which the Template writes into.

  3. #3
    Sencha User
    Join Date
    May 2008
    Posts
    180

    Default

    but then how i determine in the event function that the click was actuallu on the span and not on some other place of the enclosing component?

    Maybe i should add id to the span and after calling overwrite method of the template use Ext.get() to get my span and add the listener?

    And another question, where should i put the overwrite method call? Currently i made a delayed task in the onRender method that does the overwrite... is it ok?

  4. #4
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    By giving the span a class and using the delegate option on the listener.

    This has been covered here many times.

  5. #5
    Sencha User
    Join Date
    May 2008
    Posts
    180

    Default

    Thanks Animal, i will search the forums for the delegate option.
    Currently i am trying to get into the onclick event of the panel that i write my template into.
    I am not seeing in the documentation that there is onclick event for Panel.

  6. #6
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    This is the 18783277th time someone has wanted a DOM event from a Component.

    Add the listener to the element of the Panel that you want to add it to on render.

    Maybe you want to add a listener to the body? or the header?

Posting Permissions

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