Using Ext.XTemplate and OnClick

  • Hi I have a Ext.XTemplate where I am adding several links, I need a function to dectect the link was clicked and get the ExternaId.

    the code:

    this.previewTemplate = new Ext.XTemplate(
    '',
    '{Subject}


  • Saki let me give you more information because I don't sure about I am using in the right way the Ext.XTemplate, maybe there is other component

    I need to show an email with the address, from, cc, subject and links to the attachments, for each attachment I have the ExternaId, i'ts the Id to locate the file in the server side, I am using the Xtemplate to show this information it's working ok, but, the trouble is in detect which link was clicked and get the ExternalId to get the file from the server.

    I modified the template but using you approach don't work, (I don't have define "some-class" in my css, could be have trouble it?), the error is this.spanemailattachment.el is undefined



    /* template used in email with attchament*/
    this.previewTemplate = new Ext.XTemplate(
    '',
    '{Subject}


  • The best would be to enclose it in a span with a class. Then you can easily select it with DomQuery. E.g.:

    Text to get



    Ext.DomQuery.select('span.some-class');


  • Saki how I can click on a link inside the tpl for="attachments" and get the externalId of this link, sorry I don't understand your example, any info is welcome

    regards
    Frank


  • I wouldn't add any listener to a XTemplate generated html as it is destroyed everytime when XTemplate runs so it would lead to memory leaks. The idea is to listen to click events on a container of generated html. However, then you have to find out which link was clicked as you receive events from all links.

    My example was aimed in that direction. For example:

    container.el.on('click', function(e, t) {
    var target = t.getTarget('span.some-class');
    if(target) {
    // some processing
    }
    });


  • Frank, here is the runnable example of the concept I suggested. The only difference is that html is not generated by XTemplate:







    Link Click




    Attachment 1







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Using Ext.XTemplate and OnClick , Please add it free.