jQuery(…).yiiGridView is not a function

泪湿孤枕 提交于 2020-01-02 05:05:07

问题


I have a problem with Yii grid view. for some reason it does not seem to load correctly, even though the script is included (i can see it in the source code). This is the header part of the HTML:

<script src="fileadmin/static/js/jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="/module/public/assets/80c0553/gridview/jquery.yiigridview.js" type="text/javascript"></script>
<script type="text/javascript">jQuery(function($) {
 jQuery('#grid-downloads').yiiGridView({'ajaxUpdate':['grid-downloads'],'ajaxVar':'ajax','pagerClass':'pager','loadingClass':'grid-view-loading','filterClass':'filters','tableClass':'def-table','selectableRows':1,'enableHistory':false,'updateSelector':'{page}, {sort}','filterSelector':'{filter}','pageVar':'page'}); 
 });
</script>

I get the Error: TypeError: jQuery(...).yiiGridView is not a function

Any ideas where the problem may lie?


回答1:


I found the issue.

Actually the problem was, somehow i got jquery included 2 times in the page - the 2nd time in the footer, that is why I did't find our earlier.

Jquery needs to be only 1 time in the page, and it needs to be in the header.




回答2:


as Asped said, you must take care of assets and avoid loading jquery once in asset js and again in asset public depends like 'yii\web\JqueryAsset',.



来源:https://stackoverflow.com/questions/25603370/jquery-yiigridview-is-not-a-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!