I have a html file in my assets that I load via:
webView.loadUrl(""file:///android_asset/subfolder/myhtmldoc.html",");
Inside that html file I have a accordion-table.
So when I search via:
mwebView.findAllAsync("searchterm");
it finds only the words in the open accords....
I want to open all the accords when I search. And optimal would be to close all that does not contain the word but that comes secondary.
Inside the html I have written a jQuery function:
<script type="text/javascript">
<!-- erzeugt die akkordeonansicht zum aufklappen -->
$(document).ready(function(){
$("dt").click(function(){ // trigger
$(this).next("dd").slideToggle("fast"); // blendet beim Klick auf "dt" die nächste "dd" ein.
$(this).children("a").toggleClass("closed open"); // wechselt beim Klick auf "dt" die Klasse des enthaltenen a-Tags von "closed" zu "open".
});
});
</script>
Now how do I tell that html to slide down all the Toggles when I search inside it?
It should look somewhat like this:
mwebview.passCommand("$("dt").$(this).next("dd").slideToggle("fast");");
You can call any js function by using loadUrl
method of WebView:
mWebView.loadUrl("javascript:myFunction();");
In your case:
mWebView.loadUrl("javascript:$('dt').$(this).next('dd').slideToggle('fast');");