How to fix TypeError: jQuery(…).editable is not a function in yii2 kartik editable gridview issue

You could have a problem described below

This has been copied from https://disqus.com/home/discussion/krajee/not_found_404_kartik_439/

I am having a problem with the editable column in a gridview, I was hopingfor a point in the right direction to resolve. When I add a row in a blank grid via ajax, I reload the grid using pjax. On the Pjax reload the editable column comes up as a button and has no events triggered. Firebug reports the following error.

TypeError: jQuery(…).editable is not a function.

On a page reload after adding the first row everything works as expected. Adding a second line to the grid everything works as expected. The problem only occurs when the first row is added and the grid refreshed via pjax.

This can be fixed by loading the assets manually .

Just put this on the top of your view and it will work fine.

use kartik\editable\EditableAsset;

EditableAsset::register($this);

use kartik\editable\EditablePjaxAsset;

EditablePjaxAsset::register($this);

use kartik\popover\PopoverXAsset;

PopoverXAsset::register($this);

I have also reported it kartik here where more info can be found regards this issue.

https://github.com/kartik-v/yii2-dynagrid/issues/97

Have a happy Yii2 programming!

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s