Domplate event issue - onclick for individual elements

50 views
Skip to first unread message

Dan

unread,
Mar 1, 2014, 4:55:52 AM3/1/14
to fir...@googlegroups.com
Hi,

I'm creating a Firebug extension and struggling with domplate events.

Given 2 separate elements, each with a separate onclick handler, the same handler (onBtnOneClick) is called for both elements.

Sure, I could check the event.target, but the ui is going to get a lot more complicated than this, and surely I should be able to attach different handlers to different elements?

See the template (some of it) below.

FYI, if I delete btnOne, then onBnTwoClick is called when btnTwo is clicked.

Is this a bug, expected behaviour, or am I doing something else wrong? 

var MyPlate = domplate({

    ui: 
        TABLE({"class" : "stretch"}, 
            TR(
                TD({"class" : "fit nowrap"},
                    
                    A({"class" : "btn flush", "id" : "btnOne", onclick : "$onBtnOneClick"}, 
                        SPAN({"class" : "icon one"}),
                        " One"
                    ),

                    A({"class" : "btn", "id" : "btnTwo", onclick : "$onBtnTwoClick"}, 
                        SPAN({"class" : "icon select"}),
                        " Two"
                    )
                ),
 ......


Sebastian Zartner

unread,
Mar 2, 2014, 8:18:54 PM3/2/14
to fir...@googlegroups.com
The code seems ok. The two event handlers should work independently.
Any chance I could try out your extension?

Sebastian

Dan

unread,
Mar 3, 2014, 3:49:37 AM3/3/14
to fir...@googlegroups.com
Hi Sebastian,

Thanks for the quick reply.

Rather than complicate things with lots of unrelated code, I have created a small and simple extension which replicates the problem. The extension adds a new side panel into the HTML panel.

Reproduction steps : click btnOne and btnTwo and check the FBTrace output - you'll see that both buttons trigger the same handler.

Please see attached and let me know if you have any questions, or need anything else from me.

Thanks,

Dan
FirebugDebug.zip

Jan Honza Odvarko

unread,
Mar 3, 2014, 8:44:47 AM3/3/14
to fir...@googlegroups.com


On Saturday, March 1, 2014 10:55:52 AM UTC+1, Dan wrote:
Hi,

I'm creating a Firebug extension and struggling with domplate events.

Given 2 separate elements, each with a separate onclick handler, the same handler (onBtnOneClick) is called for both elements.

Sure, I could check the event.target, but the ui is going to get a lot more complicated than this, and surely I should be able to attach different handlers to different elements?

See the template (some of it) below.

FYI, if I delete btnOne, then onBnTwoClick is called when btnTwo is clicked.

Is this a bug, expected behaviour, or am I doing something else wrong? 

var MyPlate = domplate({

    ui: 
        TABLE({"class" : "stretch"}, 

You are missing TBODY element (Domplate requires that)

Does it help?

Honza


 

Sebastian Zartner

unread,
Mar 3, 2014, 8:56:55 AM3/3/14
to fir...@googlegroups.com
    ui: 
        TABLE({"class" : "stretch"}, 

You are missing TBODY element (Domplate requires that)
I investigated a bit in the morning but didn't think of that having any influence. Is that mentioned somewhere, i.e. in the code, in the wiki or a blog post?
 
Does it help?
It fixes the problem for me at least.

Sebastian

Jan Honza Odvarko

unread,
Mar 3, 2014, 9:14:55 AM3/3/14
to fir...@googlegroups.com


On Monday, March 3, 2014 2:56:55 PM UTC+1, Sebastian Zartner wrote:
    ui: 
        TABLE({"class" : "stretch"}, 

You are missing TBODY element (Domplate requires that)
I investigated a bit in the morning but didn't think of that having any influence. Is that mentioned somewhere, i.e. in the code, in the wiki or a blog post?
I don't know, but you can go ahead and mention it somewhere ;-)

Honza

 

Dan

unread,
Mar 3, 2014, 5:03:03 PM3/3/14
to fir...@googlegroups.com
Yes, that fixed it for me too.

I wouldn't have guessed that would have impacted the event handing either.

Thanks both for taking the time to help :)
Reply all
Reply to author
Forward
0 new messages