Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Using evalJS to update a html text area value (passing args with evalJS)

$
0
0

I'm using titanium 3.3.0 Alloy project with a webview

Im attempting to use a webView with a text area to display a string which I pass from my controller.

notes.js

$.notes_overlay.addEventListener('load',function() {
    alert("current note: " + Alloy.Globals.currentNote);
 
    //text_area = $.notes_overlay.evalJS('document.getElementById("notes_textarea")');
    //text_area.value = Alloy.Globals.currentNote;  
 
//neither of these seem to work
    $.notes_overlay.evalJS('document.getElementById("notes_textarea").value =\"' + Alloy.Globals.currentNote + "\"");
    $.notes_overlay.evalJS('document.getElementById("notes_textarea").value ="' + Alloy.Globals.currentNote + '"');
notes.xml
<Alloy>
    <Window id="notesWin">
        <WebView id="notes_overlay">
        </WebView>
 
        <ImageView id="topbar">
            <Label id="topbar_label"/>
            <Button id='save_button'/>
            <Button id='exit_button'/>
        </ImageView>
    </Window>
</Alloy>
notes.html
<html>
    <head>
        <title>Local HTML</title>
        <link rel="stylesheet" type="text/css" href="notes.css"/>
    </head>
    <body>
 
        <textarea id="notes_textarea" placeholder="Enter your text ..."> </textarea>
 
    </body>
</html>
All I want to do is populate notes_textarea.value with Alloy.Globals.currentNote but everything I have tried ends up with an empty text area after the page loads. Anything obvious that I'm doing wrong here?

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>