Как мне получить данные для отображения на init_instance_callback - PullRequest
0 голосов
/ 08 мая 2019

Я хочу инициировать текстовую область данных с помощью данных.Как мне получить данные с моего контроллера в текстовое поле tinymce?

Мне удается получить содержимое с веб-страницы на контроллер, используя метод post ajax.

Мой контроллер

@RequestMapping(value = "")
    public String incidentNotesDetail(@PathParam("id") Long id, Model model, Principal principal) {



        return "incidentNotes";
    }
@RequestMapping(value = "/update", method = RequestMethod.POST)
    public String incidentNotesDetailPost(@RequestParam("content") String content, HttpServletRequest request) {

        System.out.println(content);

        return "/incidentNotes";
    }

Мой HTML

<body>
    <h1>Incident Notes</h1>
    <form action="@{/incidentNotes/update}" method="post">
        <textarea id="myTextarea">
<table border="0" cellspacing="0" cellpadding="0" width="712">
 <tr >
    <td id="notesSn" width="25" style="border:groove" ><p align="center"><strong>S/N</strong></p></td>
    <td width="255" style="border:groove"><p align="center"><strong>Title</strong></p></td>
    <td width="101" style="border:groove"><p align="center"><strong>Timestamp</strong></p></td>
    <td width="461" style="border:groove"><p align="center"><strong>Description</strong></p></td>
  </tr>
</table>
      </textarea>
    </form>

    <script>
        tinymce
                .init({
                    selector : '#myTextarea',
                    skin : "oxide-dark",
                    height : 800,
                    plugins : [
                            "advlist autolink lists link charmap print preview anchor",
                            "searchreplace visualblocks",
                            "insertdatetime media table contextmenu paste save" ],
                    toolbar : " save | print | insertfile undo redo |styleselect | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent",
                    init_instance_callback : function(editor) {

                        tinymce.get('myTextarea').setContent("Hello");
                    },   
                    save_onsavecallback : function() {
                        var content = tinymce.activeEditor.getContent();
                        console.log(content);
                        $
                                .ajax({
                                    type : 'post',
                                    cache : false,
                                    url : "/incidentNotes/update",
                                    data : {
                                        "content" : content
                                    },
                                    success : function() {
                                        tinymce.activeEditor.windowManager
                                                .alert("This page has been successfully saved");
                                    }
                                });
                    }
                });
    </script>

Я бы хотел, чтобы текстовое поле tinymce отображало данные, которые я посылаю с контроллера.

...