Xavier,
Your function drawChart is never called. I suppose
"google.setOnLoadCallback(drawChart);" add some sort of onLoad handler but an
Ajax request will never trigger it.
A simple way that should work is to put a script after all the required HTML
elements for the graph with this content:
<script>
drawChart();
</script>
There is probably another way with AMD call back but this is tricky since the
function "drawChart" does not exists when the AMD is created.
Samuel
> Le 2015-05-04 à 11:48, Dev WO <[email protected]> a écrit :
>
> Hi Samuel,
>
> I didn’t mention the console as there was nothing there.
>
> Let’s try to give more context:)
>
> I’ve got a component which is supposed to be the content of the modal dialog,
> let’s call it “Chart”
> This component is
> <wo:str value = "$googleChartGenerationString" escapeHTML = "$false"/>
> <div id = "chart_points" style = "width: 1000px; height: 600px;">TEST</div>
>
> The $googleChartGenerationString generate something like this for example:
> <script>
> google.setOnLoadCallback(drawChart);
> function drawChart() {
> var data = new google.visualization.DataTable();
> data.addColumn('datetime', 'Date');
> data.addColumn('number', 'Points');
> data.addRows([
> [new Date(2015, 4, 3, 23, 44, 48), 1247],
> [new Date(2015, 4, 3, 23, 47, 43), 1247],
> [new Date(2015, 4, 4, 0, 24, 43), 1247],
> [new Date(2015, 4, 4, 4, 34, 55), 1247]]);
> var options = {
> curveType: 'none',
> legend: 'none',
> width: 900,
> height: 500
> };
> var chart = new google.charts.Line(document.getElementById('chart_points'));
> chart.draw(data, options);
> }
> </script>
>
> If I’m placing this component inline in its parent component (which is called
> via a regular component action, meaning the parent isn’t called from an ajax
> request), everything is fine, the chart is displayed.
>
> If I’m placing the component in the “content” part of an AMD, I can see that
> it still gets the expected content (using the browser console), but nothing
> is displayed, even the “TEST” string isn’t removed which is also why I think
> the javascript isn’t executed at all.
>
> So I’m kind of puzzled as to what could prevent my “manual" javascript from
> being executed when requested inside an AMD.
>
> I don’t really have much more context than this:(
>
> Xavier
>
>
>
>
>> On 4 mai 2015, at 16:22, Samuel Pelletier <[email protected]
>> <mailto:[email protected]>> wrote:
>>
>> Xavier,
>>
>> Have look at the javascript console, if there is javascript error, it is
>> probably your problem. If there is nothing there, you should put way more
>> context to explain what you want to achieve and how you tried so far.
>>
>> Samuel
>>
>>
>>> Le 2015-05-04 à 09:28, Dev WO <[email protected]
>>> <mailto:[email protected]>> a écrit :
>>>
>>> Hi All,
>>>
>>> I’m trying to display a chart generated with Google Chart inside an AMD.
>>>
>>> For the Google Chart part, I’m generating a javascript function which is
>>> then “written” into the HTML with a simple wo:string/escape=false directly
>>> inside the AMD content.
>>>
>>> If I display it inline with the page, everything is fine. But if I try to
>>> display it through an AMD, the javascript isn’t triggered at all.
>>> It is there, I can see the response (and it works inline for example), but
>>> it doesn’t display/execute at all.
>>> I believe it’s not triggered at all because the js update the content of a
>>> div, and when called through the AMD the “default" content isn’t changed.
>>>
>>> I’ve tried using the afterLoad and afterResize bindings of the AMD to
>>> trigger the javascript, but it doesn’t do anything.
>>>
>>> Anyone has any pointer on how to get my javascript executed inside the AMD?
>>>
>>> Thanks a lot,
>>>
>>> Xavier
>>>
>>>
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Webobjects-dev mailing list ([email protected]
>>> <mailto:[email protected]>)
>>> Help/Unsubscribe/Update your Subscription:
>>> https://lists.apple.com/mailman/options/webobjects-dev/samuel%40samkar.com
>>> <https://lists.apple.com/mailman/options/webobjects-dev/samuel%40samkar.com>
>>>
>>> This email sent to [email protected] <mailto:[email protected]>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]