te')); return $arr; } /* 遍历用户所有主题 * @param $uid 用户ID * @param int $page 页数 * @param int $pagesize 每页记录条数 * @param bool $desc 排序方式 TRUE降序 FALSE升序 * @param string $key 返回的数组用那一列的值作为 key * @param array $col 查询哪些列 */ function thread_tid_find_by_uid($uid, $page = 1, $pagesize = 1000, $desc = TRUE, $key = 'tid', $col = array()) { if (empty($uid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('uid' => $uid), array('tid' => $orderby), $page, $pagesize, $key, $col); return $arr; } // 遍历栏目下tid 支持数组 $fid = array(1,2,3) function thread_tid_find_by_fid($fid, $page = 1, $pagesize = 1000, $desc = TRUE) { if (empty($fid)) return array(); $orderby = TRUE == $desc ? -1 : 1; $arr = thread_tid__find($cond = array('fid' => $fid), array('tid' => $orderby), $page, $pagesize, 'tid', array('tid', 'verify_date')); return $arr; } function thread_tid_delete($tid) { if (empty($tid)) return FALSE; $r = thread_tid__delete(array('tid' => $tid)); return $r; } function thread_tid_count() { $n = thread_tid__count(); return $n; } // 统计用户主题数 大数量下严谨使用非主键统计 function thread_uid_count($uid) { $n = thread_tid__count(array('uid' => $uid)); return $n; } // 统计栏目主题数 大数量下严谨使用非主键统计 function thread_fid_count($fid) { $n = thread_tid__count(array('fid' => $fid)); return $n; } ?>javascript - jQuery(...).yiiGridView is not a function - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery(...).yiiGridView is not a function - Stack Overflow

programmeradmin3浏览0评论

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?

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?

Share Improve this question asked Sep 1, 2014 at 10:04 AspedAsped 3,1034 gold badges34 silver badges53 bronze badges 3
  • 2 maybe it's because jquery or that exact library is included multiple times – Developerium Commented Sep 1, 2014 at 10:23
  • 1 thanks! actually this was really the problem, somehow i got jquery included 2nd time also in the footer of the page, and that broken the code – Asped Commented Sep 1, 2014 at 10:38
  • 1 move jquery js file inclusion to the head section in layount/main.php file. I had mine in footer section of my theme, as I moved it to head section, jquery/js function calling started working :) – iltaf khalid Commented Jan 14, 2015 at 10:07
Add a ment  | 

2 Answers 2

Reset to default 13

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.

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',.

发布评论

评论列表(0)

  1. 暂无评论