Question of the Twitter’s button API twttr.events.bind(‘click’, function()) and event.target


#1

Are you able to offer me some simple code of how to use twttr.events.bind(‘click’, function()) and event.target to see which node in the page was clicked?

Please refer to https://dev.twitter.com/discussions/4953 to see the detail, I want to differentiate the Twitter button on page header and page body, but I don’t know the detail of this API, it always return “object”, I’ve no idea of how to use this API to check and see the content of the return value.


#2

The “object” that you get back in event.target is a DOM element and you can do anything you can do with a DOM element in Javascript with it. Here’s an example of opening a Javascript alert with the ID of the DOM node:

twttr.events.bind('click', captureElement); function captureElement(event) { var dom_element = event.target; var dom_id = dom_element.id; var dom_class_name = dom_element.className; alert("The DOM element that was clicked had this id: " + dom_id + ". And class name: " + dom_class_name); }

#3

is it possible to pass some values to the called function…
wrapping the code with in the following code disables the normal tweet button…
i ma trying the codes like this

twttr.ready(function (twttr) { twttr.events.bind('tweet', twitnshare('tws_likings', '<?php echo $sess_uid;?>', href)); });

#4

I could work it out with by modifying the code like this one below

but the same thing creates problem as i have same tweet button put onto while loop and hence it gets triggered as many times as the while loop has been set to run…??


#5

#6