3
votes

Should I use another variable for "streszczenie"? or what should I do?

In my opinion in TinyMCE body have html but I get only "\t" Pobably I have got problem with JS

this is new problem - this question is related with this link. I added this for other users

this I write in TinyMCE

enter image description here

this I get from TinyMCE textarea "streszczenie"

enter image description here

As you can see there is text ghhfgh but I can`t get this text

enter image description here

Now I have got problem with execute JSON

<script type="text/javascript">

    function Save() {
        tinyMCE.triggerSave();
        var Temat_controll = $('#Temat').val();
        var Streszczenie_controll = tinyMCE.get('Streszczenie').getContent();
        var PelnyOpis_controll = $('#PelnyOpis').text();

            $.ajax({
                url: '@Url.Action("DodajTematSave", "StronaGlowna")',
                dataType: "json",
                data: { 
                    Temat: Temat_controll,
                    Streszczenie: Streszczenie_controll,
                    PelnyOpis: PelnyOpis_controll
                },
                type: "POST",
                async: false,
                error: function() {
                },
                success: function(data) {
                    if (data.Success) {
                        alert('success');
                    }

                }
            });
        }

</script>

I get this but all the time JSON is not execute

enter image description here

When I click button tinyMCE.get('Streszczenie').getContent() is empty I check this and I don`t know why because I have got text into textarea

<script type="text/javascript">

    function Save() {
        var Temat_controll = $('#Temat').val();
        var $d = tinyMCE.get('Streszczenie').getContent();
        if ($d.length != 0) {
            if ($d.val().length != 0) {
                var Streszczenie_controll = tinyMCE.get('Streszczenie').getContent();
            }
            else {
                var Streszczenie_controll = 'ewewe';
            }
        }
        var PelnyOpis_controll = $('#PelnyOpis').text();

        $.ajax({
            url: '@Url.Action("DodajTematSave", "StronaGlowna")',
            dataType: "json",
            data: {
                Temat: Temat_controll,
                Streszczenie: Streszczenie_controll,
                PelnyOpis: PelnyOpis_controll
            },
            type: "POST",
            async: false,
            error: function () {
            },
            success: function (data) {
                if (data.Success) {
                    alert('success');
                }

            }
        });
    }

</script>
1
This link can be also useful to understand JSON problem [click here][1] [1]: stackoverflow.com/questions/15600396/json-data-html-parameterRafał Developer

1 Answers

4
votes

You are getting the content in wrong way, not by jQuery's val().

To get the tinymce content, just use tinyMCE object reference:

// Get the HTML contents of the currently active editor
console.debug(tinyMCE.activeEditor.getContent());

// Get the raw contents of the currently active editor
tinyMCE.activeEditor.getContent({format : 'raw'});

// Get content of a specific editor:
tinyMCE.get('content id').getContent()

As mentioned: http://www.tinymce.com/wiki.php/API3:method.tinymce.Editor.getContent

Hope it heled. Polish man : )