Tried doing this in Chrome:

 google.visualization.events.addListener(chart, 'ready', function() {
    var location_chart_element = $('#location_chart 
iframe').contents().find('div');
      $(location_chart_element).click(function (event){
alert('hello world');
      })
    });


And even though I can see location_chart_element in the console log as an 
array of divs, the listener is not being triggered.

I don't know if I am missing something compared to what you suggested, but 
I have tried to isolate the chart in a single page and is happening the 
same.  Do you see what might I be wrong?

On Monday, June 25, 2012 1:16:00 PM UTC-7, asgallant wrote:
>
> That should work, but I can see that it doesn't in IE.  This does:
>
> $('#location_chart iframe').contents().find('div').click(function (event) {
>     alert('hello world');
> });
>
> On Monday, June 25, 2012 4:05:09 PM UTC-4, novito wrote:
>>
>> I see the element in the console. I have even make sure the chart is 
>> ready, but it seems the click even is not firing.  Have you been able to 
>> reproduce this? 
>>
>> On Monday, June 25, 2012 12:46:33 PM UTC-7, asgallant wrote:
>>>
>>> Try this:
>>>
>>> $('#location_chart iframe').contents().find('#chartArea').click(function 
>>> (event) {
>>>     alert('hello world');
>>> });
>>>
>>> On Monday, June 25, 2012 3:28:45 PM UTC-4, novito wrote:
>>>>
>>>> I have tried doing this:
>>>>
>>>>  var iframeDoc = $('#location_chart iframe').contents().get(0);
>>>>      console.log(iframeDoc);
>>>>      $(iframeDoc).bind('click', function(event ){
>>>>       alert('hello world');
>>>>      });
>>>>
>>>> But it seems is not binding correctly... Would this be a good approach?
>>>>
>>>> On Monday, June 25, 2012 11:56:52 AM UTC-7, novito wrote:
>>>>>
>>>>> I have rendered some charts with the forceIframe attribute set to 
>>>>> false, so the chart is rendered as SVG and I can add a listener whenever 
>>>>> that SVG is clicked.  I do that because with the Iframe there is no way 
>>>>> that I can listen for a click on all the chart (not just the elements) 
>>>>> container.
>>>>>
>>>>> However, when trying to use this attribute and rendering the charts on 
>>>>> IE8, the chart is rendered within an Iframe, and therefore when I do this:
>>>>>
>>>>> google.visualization.events.addListener(chart, 'ready', function() {
>>>>>     
>>>>> document.getElementById('location_chart').getElementsByTagName('svg')[0].onclick
>>>>>  
>>>>> = function() {
>>>>>       drawCenteredChart();
>>>>>     };
>>>>>   });
>>>>>
>>>>> It breaks, because there is no SVG element.  So my question is:  What 
>>>>> would be a good solution for this?  Why is not rendering the SVG?
>>>>>
>>>>> Thanks
>>>>>
>>>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-visualization-api/-/bMwomqVkUpQJ.
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 
http://groups.google.com/group/google-visualization-api?hl=en.

Reply via email to