On Aug 28, 7:08 am, Malintha <[email protected]> wrote:
> Hi,
>
> I want to access domplate tag on my button click function.It will look like
> this.
>
> Domplate{
>
> myTag:
>          DIV("Hello World!"),
>
> onclick: function(event){
>
>         this.myTag();
>
> }
>
> /////////////////////
> Is this correct? Or how can do it ?
No, you need to specify the listener in the template,
see the "onclick" property in the following example:

var template = domplate(
{
    tag:
        BUTTON({onclick: "$onLabelClick"}, "$object.label"),

    onLabelClick: function(event)
    {
        alert("Click!")
    }
});

template.tag.replace({object: inputObject}, parentNode, template);

> Actually what i want to do is display more data on domplate when i click a
> button on the domplate . Can I do that ?
Sure, you can handle the click and use standard DOM methods
such as appendChild or render another template.

E.g.

onLabelClick: function(event)
{
    var target = event.target;
    var parentNode = target.... // Use DOM method to get the right
parentNode

    // Render another template
    anotherTemplate.tag.replace({object: inputObject}, parentNode);
}

Honza

-- 
You received this message because you are subscribed to the Google
Groups "Firebug" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
https://groups.google.com/forum/#!forum/firebug

Reply via email to