Sending data from dialog box to the index page text editor

lulu50
lulu50 used Ask the Experts™
on
Hi,

1. I have an index page
2. I have a dialog window
3. I want to send data from my dialog window to the index page

I'm unable to send my data from the dialog box to the index page text editor.


index page: 

text editor 


   jQuery(function () {
            var maxLength4000 = 4000;
            $(document).on("keyup paste touchend", function () {
                var text = $("#ActionAttributesAndValues").val();
                var textlen = maxLength4000 - text.length;
                if (text.length > 4000) {
                    editorActionAttributesAndValues.value = text.substr(0, 4000);
                }
                $('#rcharsActionAttributesAndValues').text(textlen);

                if ($("#ActionAttributesAndValues").val() != '') {
                    $('#ValidateActionAttributesAndValues').hide();
                }
                else {
                    $('#ValidateActionAttributesAndValues').show();
                }
            });
            var editorActionAttributesAndValues = new Jodit("#ActionAttributesAndValues");
        });



  @Html.TextArea("ActionAttributesAndValues", new { @class = "form-control", @style = "width:77%" })

Open in new window




Dialog window: 

 $("#AppendAttributeToParentBtn").click(function () {
            debugger;

         // I want to populate the editor Attribute value to Attribute text editor. 
        // it's not working 

             var textareavalue = editorAttributeTextArea.value;
            alert(textareavalue);   //I'm getting the data from the text area but I'm unable to send my data to the index page where I have the editor for attribute text editor 

            editorActionAttributesAndValues.value = editorActionAttributesAndValues.value + '<br/>' + textareavalue;
          
 
        });

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Multitechnician
Top Expert 2014
Commented:
put the following likne 5, just before jQuery(function() {

var editorActionAttributesAndValues = null;

replace line 23 by (we removed the var as we already declared it) :
editorActionAttributesAndValues = new Jodit("#ActionAttributesAndValues");
lulu50Web application

Author

Commented:
I'm getting an error on my dialog box :

Unhandled exception at line 59, column 13 in eval code

0x800a1391 - JavaScript runtime error: 'editorActionAttributesAndValues' is undefined

//on my index page

  var editorActionAttributesAndValues = null;
        jQuery(function () {
            var maxLength4000 = 4000;
            $(document).on("keyup paste touchend", function () {
                var text = $("#ActionAttributesAndValues").val();
                var textlen = maxLength4000 - text.length;
                if (text.length > 4000) {
                    editorActionAttributesAndValues.value = text.substr(0, 4000);
                }
                $('#rcharsActionAttributesAndValues').text(textlen);

                if ($("#ActionAttributesAndValues").val() != '') {
                    $('#ValidateActionAttributesAndValues').hide();
                }
                else {
                    $('#ValidateActionAttributesAndValues').show();
                }
            });
            //var editorActionAttributesAndValues = new Jodit("#ActionAttributesAndValues");
            editorActionAttributesAndValues = new Jodit("#ActionAttributesAndValues");
        });


// on my dialog box

 $("#AppendAttributeToParentBtn").click(function () {
            debugger;

            var textareavalue = editorAttributeTextArea.value;
            alert(textareavalue);

              // I'm getting the error here "JavaScript runtime error: 'editorActionAttributesAndValues' is undefined"

            editorActionAttributesAndValues.value = editorActionAttributesAndValues.value + '<br/>' + textareavalue;
            

        });

Open in new window

lulu50Web application

Author

Commented:
Maybe because I have two text editors on the index page

first one

  jQuery(function () {
            var maxLength4000 = 4000;
            $(document).on("keyup paste touchend", function () {
                var text = $("#ConditionAttributesAndValues").val();
                var textlen = maxLength4000 - text.length;
                if (text.length > 4000) {
                    editor.value = text.substr(0, 4000);
                }
                $('#rcharsConditionAttributesAndValues').text(textlen);

                if ($("#ConditionAttributesAndValues").val() != '') {
                    $('#ValidateConditionAttributesAndValues').hide();
                }
                else {
                    $('#ValidateConditionAttributesAndValues').show();
                }
            });
            editor = new Jodit("#ConditionAttributesAndValues");
        });
       


        var editorActionAttributesAndValues = null;
        jQuery(function () {
            var maxLength4000 = 4000;
            $(document).on("keyup paste touchend", function () {
                var text = $("#ActionAttributesAndValues").val();
                var textlen = maxLength4000 - text.length;
                if (text.length > 4000) {
                    editorActionAttributesAndValues.value = text.substr(0, 4000);
                }
                $('#rcharsActionAttributesAndValues').text(textlen);

                if ($("#ActionAttributesAndValues").val() != '') {
                    $('#ValidateActionAttributesAndValues').hide();
                }
                else {
                    $('#ValidateActionAttributesAndValues').show();
                }
            });
           // var editorActionAttributesAndValues = new Jodit("#ActionAttributesAndValues");
            editorActionAttributesAndValues = new Jodit("#ActionAttributesAndValues");
        });

Open in new window



If I do:

editor.value = editor.value + '<br/>' + textareavalue;

it will go to the first text editor but not the second
I want it to go to the second text editor.

editorActionAttributesAndValues.value = editorActionAttributesAndValues.value + '<br/>' + textareavalue;
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

lulu50Web application

Author

Commented:
Hi,

It worked!!!!

 var editorActionAttributesAndValues = null;
        jQuery(function () {
            var maxLength4000 = 4000;
            $(document).on("keyup paste touchend", function () {
                var text = $("#ActionAttributesAndValues").val();
                var textlen = maxLength4000 - text.length;
                if (text.length > 4000) {
                    editorActionAttributesAndValues.value = text.substr(0, 4000);
                }
                $('#rcharsActionAttributesAndValues').text(textlen);

                if ($("#ActionAttributesAndValues").val() != '') {
                    $('#ValidateActionAttributesAndValues').hide();
                }
                else {
                    $('#ValidateActionAttributesAndValues').show();
                }
            });
            editor.editorActionAttributesAndValues = new Jodit("#ActionAttributesAndValues");
        });


        $("#AppendAttributeToParentBtn").click(function () {
            var textareavalue = editorAttributeTextArea.value;
            editor.editorActionAttributesAndValues.value = editor.editorActionAttributesAndValues.value + '<br/>' + textareavalue;
        });

Open in new window

lulu50Web application

Author

Commented:
Thank you so much!!!!

This is great!!!!

Thank you for all your help.

Thanks,
Lulu50
leakim971Multitechnician
Top Expert 2014

Commented:
you welcome

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial