1

I have the following code in a custom module for admin backend, which is not running.

tinymce.html

<textarea class="admin__control-textarea wysiwyg" data-bind="
    value: value,
    valueUpdate: valueUpdate,
    hasFocus: focused,
    attr: {
        name: inputName,
        cols: cols,
        rows: rows,
        'aria-describedby': noticeId,
        placeholder: placeholder,
        id: uid,
        disabled: disabled
    }"
/>

<script type="text/javascript">
    require(['jquery'], function($){
        $(document).ready(function() {
            alert("inside tinymce template");
        });
   });
</script>

This produces the following HTML code

<textarea class="admin__control-textarea wysiwyg" data-bind="
    value: value,
    valueUpdate: valueUpdate,
    hasFocus: focused,
    attr: {
         name: inputName,
         cols: cols,
         rows: rows,
         'aria-describedby': noticeId,
         placeholder: placeholder,
         id: uid,
         disabled: disabled
     }" name="caption" cols="15" rows="2" aria-describedby="notice-I1P21H3" placeholder="" id="I1P21H3"></textarea>

<script type="text/javascript">
     require(['jquery'], function($){
         $(document).ready(function() {
            alert("inside tinymce template");
         });
     });
</script>

However, the alert is never fired.

  • Welcome to Magento StackExchange! what version of Magento are you using? – diazwatson Aug 8 '17 at 8:38
  • Did you create js file of tinymce.html? – Rakesh Jesadiya Aug 8 '17 at 8:45
  • I'm on Magento 2.1.7 – Mark Aug 8 '17 at 8:48
  • Hi Rakesh. I've not created a JS file. I didn't think I needed to as I'm using the jQuery Library. What would go in tinymce.js and where should that be linked from? – Mark Aug 8 '17 at 8:50
  • First, You cant call js file in your html file except knockout code, You have to keep your js code inside your html file js file. – Rakesh Jesadiya Aug 8 '17 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.