Link to home
Start Free TrialLog in
Avatar of lulu50
lulu50Flag for United States of America

asked on

Sending data from dialog box to the index page text editor

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

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lulu50

ASKER

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

Avatar of lulu50

ASKER

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;
Avatar of lulu50

ASKER

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

Avatar of lulu50

ASKER

Thank you so much!!!!

This is great!!!!

Thank you for all your help.

Thanks,
Lulu50
you welcome