iam working on iOS project and there is a statistics page is already done with JS and when loading it into UIWebView everything works fine with a nice Animation
[WebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"]isDirectory:NO]]];
and the JS code is executed in document.Ready when the DOM is ready..
$(document).ready(function () {
var s1 = [[2002, 112000], [2003, 122000], [2004, 104000], [2005, 99000] ];
});
My problem is the data is generated in IOS and i want to pass this data to the JS to draw the chart with a nice animation,,i didn't find a way to pass a parameter to document.Ready so i make this a function and in IOS call this function and pass the parameters... so i changed my code to ..
-(void)webViewDidFinishLoad:(UIWebView *)webView
{
NSString * param = @"foo";
NSString * jsCallBack = [NSString stringWithFormat:@"myFunc('%@')",param];
[webViewstringByEvaluatingJavaScriptFromString:jsCallBack];
[webView stringByEvaluatingJavaScriptFromString:jsCallBack];
}
and the JS to
function myFunc (var x) {
var s1 = [[2002, 112000], [2003, 122000], [2004, 104000], [2005, 99000] ];
};
doing that actually passing parameters BUT the animation doesn't appear anymore for reason i don't know and i have tried this with lots of online ready jS charts when i change the function from document.Ready to another function gets called by IOS they appear but don't animate ....So is there is anyWay to pass a parameters to document.Ready ??