Issue #3342Opened March 17, 2021by RutujaBadbe0 reactions

jQuery not working for script in component

Question

Hi! I have tried adding jquery in canvas as well as in index.html I am adding it in canvas like this- canvas = editor.Canvas; const script1 = document.createElement('script'); script1.src = 'https://code.jquery.com/jquery-3.6.0.min.js'; canvas.getDocument().head.appendChild(script1);

and in html page I have added it as script tag - <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

now , I have a component inside which I am defining a script.

editor.DomComponents.addType('foo-button', {
        model: {
            defaults: {
                tagName: "button",
                classes: 'foo',
                //name: "Button",
                content: "Button",
                script: function() {
                    $('.foo').click(function(){
                        alert("Meow");
                    });
                }
            }
        }
    })
    editor.BlockManager.add("button1", {
        label: "Button",
        content: { type: 'foo-button' }
    });

but it is still giving me error - Uncaught ReferenceError: $ is not defined Capture

What is it that I am doing wrong? Please help.

Answers (1)

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.