By using Elementorforum.com’s services you agree to our Cookies Use and Data Transfer outside the EU.
We and our partners operate globally and use cookies, including for analytics, personalisation, ads and Newsletters.

  • Join the Best Unofficial Elementor Support forum

    Provide or get advice on everything Elementor and Wordpress, ask questions, gain confirmation or just become apart of a friendly, like minded community who love Wordpress and Elementor


    Join us!
elementor official

Question Custom Elementor Control: Docs are broken, javascript error

B

bwheeler

New Member
Hi All,
I'm following along on the "Creating a Custom Control" (can't make a link but it's at code.elementor.com/creating-a-new-control/) docs and running into an error. My javascript is throwing an error because it's not loading in the correct order on the page. My enqueue function looks like this:


PHP:
    public function enqueue(){wp_register_script('project-reference-control', FREEBSD_ELEMENTOR_URL . 'js/freebsd-elementor-project-reference-control.js', [ 'jquery'], '1.0.0' );
        wp_enqueue_script('project-reference-control');
    }
And my javscript looks like this:

JavaScript:
console.log('here');
var projectReferenceItemView = elementor.modules.controls.BaseData.extend({
    onReady: function (){console.log(this.ui);
    },
    saveValue: function (){this.setValue(
          this.ui.textarea[0].emojioneArea.getText());
    },
    onBeforeDestroy: function (){this.saveValue();
        this.ui.textarea[0].emojioneArea.off();
    }
});
elementor.addControlView('project_reference', projectReferenceItemView);
I'm getting a javascript error, elementor is undefined. If I try to add 'elementor-editor' to the list of dependencies for the script, I get even more errors and the page won't load at all:

backbone.marionette.min.js?ver=2.4.5:22 Uncaught constructor {name: "NoTemplateError", message: "Could not find template: "#tmpl-elementor-section-content"", stack: "NoTemplateError: Could not find template: "#tmpl-e…ets/js/editor-document.min.js?ver=2.8.3:2:128184)"}
backbone.marionette.min.js?ver=2.4.5:22 Uncaught constructor {name: "NoTemplateError", message: "Could not find template: "#tmpl-elementor-repeater-row"", stack: "NoTemplateError: Could not find template: "#tmpl-e…ntor/assets/js/editor.min.js?ver=2.8.3:31:183110)"}
freebsd-elementor-project-reference-control.js?ver=1.0.0:1 here
freebsd-elementor-project-reference-control.js?ver=1.0.0:2 Uncaught ReferenceError: elementor is not defined
at freebsd-elementor-project-reference-control.js?ver=1.0.0:2
Also if the docs could be fixed, that would be great. Please let me know if I should post this in the github repo instead.
 
elementor official
Koni Kodes

Koni Kodes

Member
You should definitely post this in the GitHub repo. Hopefully one of the devs can help you with that.
 
elementor official

Latest posts

Other Elementor Resources

elementor official
elementor official
Top