Uncaught TypeError: Cannot read property 'plugin' of undefined

user2359967 picture user2359967 · Aug 1, 2013 · Viewed 15.2k times · Source

I'm using Jeditable plugin of Mika Tuupola with autogrowing. I've followed his indications but the console shows this error:

enter image description here

I'm using Symfony2 with fosjsroutingbundle; this is the reason for use the variable of editable. This works fine.

This is the JS code:

 $('.editarContenido').editable(Routing.generate('criContenido_ajax.' + $('html').attr('lang'), { "_locale": $('html').attr('lang'), "pysStr": $('section').attr('pelicula') }),
        { 
            type      : "autogrow",
            submit    : 'OK',
            indicator : 'Saving...',
            tooltip   : 'Click to edit...',
            autogrow : {
                lineHeight : 16,
                maxHeight  : 512
            }
        });

        $.editable.addInputType('autogrow', {
            element : function(settings, original) {
                var textarea = $('<textarea>');
                if (settings.rows) {
                    textarea.attr('rows', settings.rows);
                } else {
                    textarea.height(settings.height);
                }
                if (settings.cols) {
                    textarea.attr('cols', settings.cols);
                } else {
                    textarea.width(settings.width);
                }
                $(this).append(textarea);
                return(textarea);
            },
            plugin : function(settings, original) {
                $('textarea', this).autogrow(settings.autogrow);
            }
        });

EDIT

enter image description here

Answer

Uku Loskit picture Uku Loskit · Aug 1, 2013

The error indicates that you do not have jQuery in place or it is placed in the HTML document after the jEditable plugin.

Make sure your scripts tags are sorted just like in the source code of this page: http://www.appelsiini.net/projects/jeditable/custom.html and all of them are properly loading.

Edit: regarding your new error: you will have to use an older version of jQuery than 1.9, as browser detection was removed beginning with that version.