google-code-export / wiquery

Automatically exported from code.google.com/p/wiquery
MIT License
1 stars 1 forks source link

Java Script errors on Ajax requests #193

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Get hold of hightchart (http://www.highcharts.com/)
2.Create some java script for a simple chart
3.Try creating the chart on an ajax request in IE

What is the expected output? What do you see instead?
The chart should work as normal. It actually produces an error deep within 
jquery. I've discovered that this was because the javascript was running too 
quickly - I'm guessing before the markup was updated. I've altered my 
WiQueryPlugin to render the javascript itself through Wicket and not by 
returning it in statement(). For ajax requests I'm using 
AjaxRequestTarget.get().appendJavascript() which is working.

What version of the product are you using? On what operating system?
1.2.3, windows, with IE8 (works in other browsers)

Original issue reported on code.google.com by fishca...@gmail.com on 23 Jun 2011 at 1:44

GoogleCodeExporter commented 9 years ago
Does your statement() function return something like:

return new JsQuery(this).$().chain("highchart");

This ensures that the jquery code is fired upon domready and not instantly.

Original comment by hielke.hoeve on 23 Jun 2011 at 2:16

GoogleCodeExporter commented 9 years ago
This will render the following javascript:

$(document).ready(function() {
$('#idc').dropDownChoice();
}

Note that this javascript and the above java code are only examples.

Original comment by hielke.hoeve on 23 Jun 2011 at 2:18

GoogleCodeExporter commented 9 years ago
Here's what it was before I changed to my method:

final JsStatement statement = new JsQuery().document().ready(
        new JsScope() {
            @Override
            protected void execute(final JsScopeContext scopeContext) {
                final ObjectMapper mapper = new ObjectMapper();
                // Setup the options for this graph instance
                setupOptions();
                try {
                    // Map the options to JSON
                    final String optionsJson = mapper
                            .writeValueAsString(options);
                    // Add the javascript to the component
                    scopeContext.append("new Highcharts.Chart("
                            + optionsJson + ");");
                } catch (final JsonGenerationException e) {
                    throw new UnhandledException(e);
                } catch (final JsonMappingException e) {
                    throw new UnhandledException(e);
                } catch (final IOException e) {
                    throw new UnhandledException(e);
                }
            }
        });
LoggerFactory.getLogger(this.getClass()).debug(
        statement.getStatement().toString());
return statement;

Original comment by fishca...@gmail.com on 23 Jun 2011 at 2:19

GoogleCodeExporter commented 9 years ago
Check this class, it also uses wiquery to build highcharts:
https://github.com/hielkehoeve/wiquery-highcharts/blob/master/src/main/java/nl/t
opicus/whighcharts/components/WHighChart.java

wiquery already adds the document ready statement and appends all statement() 
output into this. having double nested document ready statements could break 
things.

Original comment by hielke.hoeve on 27 Jun 2011 at 8:07

GoogleCodeExporter commented 9 years ago

Original comment by hielke.hoeve on 17 Aug 2011 at 8:06