Submitting a form using the Dojo Rich Text Editor

Does anyone know how to submit a form containing Dojo Rich Text Editor?

I tried to add the "name" attribute to my element, which is decorated with dojoType = "dijit.Editor", however I do not see any of the HTML in my receiving process.

I checked the documentation and I see no clear example (other than connecting to the form submission event in question, with another function that sets the hidden input data with a "Rich Text Editor value").

I would suggest that there should be a “simpler” way for this?

+3
source share
1 answer

im .

<html>
<head>
<style type="text/css">
    @import "http://ajax.googleapis.com/ajax/libs/dojo/1.5/dijit/themes/claro/claro.css";   
</style>        
<script src="djlib/dojo/dojo.js" type="text/javascript" djConfig="parseOnLoad:true"></script>   
 <link rel="stylesheet" href="djlib/dojox/grid/resources/Grid.css" type="text/css" />
<body class="claro">
    <?php if(count($_POST) > 0) {
            echo '<script>function dumpSubmittedEditorValue(){}</script>';
            echo "<script>var submittedEditorValue = '$_POST[ed1]'</script> ";
        } 
    ?>
    <form jsId="frm1" dojoType="dijit.form.Form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
        <input type="hidden" name="ed1" />
        <span dojoType="dijit.form.Button">
            Submit
            <script type="dojo/method" event="onClick">
                frm1.submit();
            </script>
        </span>
    </form>
    <div  dojoType="dijit.Editor" id="editor1">         
        <script type="dojo/method">
            this.hiddenField = dojo.query("[name=ed1]")[0];
            //console.log(this.hiddenField);
            /*dojo.connect(this.document.body,'onload',function(){                  
                console.log("A");
                console.log(this.document.body);
            })*/
        </script>
        <script type="dojo/method" event="onChange" args="val">
            //1st format. <p>     hi - should be - <p>HI
            var str = dojo.string.trim(val);

            var tagsEncoded = dojox.html.entities.encode(str, encodecustomMap);
            var whiteSpaceEncoded= tagsEncoded.replace(/\s/ig,"%20");
            this.hiddenField.value = whiteSpaceEncoded;
            console.log(this.hiddenField.value)
            //console.log(dojox.html.entities.decode(whiteSpaceEncoded.replace(/%20/ig," "), decodecustomMap))


        </script>


    </div>
    <script>
        var decodecustomMap = [                 
                ["\u003C", "lt"],
                ["\u003E", "gt"],
                ["\u0026", "amp"]
            ];
            var encodecustomMap =  [
                ["\u003C", "lt"],
                ["\u003E", "gt"]
            ];
    </script>
</body>

<script>      
    dojo.require("dijit.Editor");
    dojo.require("dojox.html.entities");
    dojo.require("dijit.form.Form");

    dojo.addOnLoad(function(){
        console.log(dojo.query("iframe", dijit.byId("editor1").domNode))
        dojo.connect(dojo.query("iframe", dijit.byId("editor1").domNode)[0],'onload',function(){
            console.log(this.contentDocument.body)
            this.contentDocument.body.innerHTML = getEditorIntialValue();
        })
        function getEditorIntialValue(){
            if(typeof submittedEditorValue != "undefined"){
                submittedEditorValue = dojox.html.entities.decode(submittedEditorValue,decodecustomMap);
                submittedEditorValue  = submittedEditorValue.replace(/%20/ig,"&nbsp;");
                return submittedEditorValue;
                //dijit.byId("editor1").document.body.innerHTML = submittedEditorValue;
            }
            else{
                return "";
            }
        }

    })
</script>
</html>
+3

All Articles