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 - Adding bootstrap.js to browserify? - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Adding bootstrap.js to browserify? - Stack Overflow

programmeradmin2浏览0评论

So I am trying to figure out how to do this? I downloaded bootstrap-sass via bower and added the bootstrap javascript into a shim.

A few things have me confused, the bootstrap.js file looks like this.

//= require bootstrap/affix
//= require bootstrap/alert
//= require bootstrap/button
//= require bootstrap/carousel
//= require bootstrap/collapse
//= require bootstrap/dropdown
//= require bootstrap/tab
//= require bootstrap/transition
//= require bootstrap/scrollspy
//= require bootstrap/modal
//= require bootstrap/tooltip
//= require bootstrap/popover

This is kind of self explanatory, but still confusing at the same time, do I leave it mented like that? When I add to the bootstrap shim do I include just the bootstrap.js file, or should I link to all the ones I need?

Just to save myself from hacking away (which I will be doing in the meantime), I'd like to try to get some information on how to include bootstrap.js into browserify.

Edit: I think I might just have to concat all the files I need and include that script, because when I browserify the bootstrap.js I just get the above.

I'll try without the ments, then if that fails I'll concat all the scripts into one file and see what happens :)

Edit: Hmm looks like the concat theory works! The only thing is jQuery, take a look.

; jQuery = global.jQuery = require("c:\\wamp\\www\\mysite\\app\\client\\requires\\jquery\\js\\jquery.js");
/* ========================================================================
 * Bootstrap: affix.js v3.1.1
 * 
 * ========================================================================
 * Copyright 2011-2014 Twitter, Inc.
 * Licensed under MIT ()
 * ======================================================================== */

This is my piled browserify code, the only way to get it to work when I call a bootstrap function say for example $('body').modal('toggle') I have to change the jQuery above to $ manually.

I tried using both inside my shim but still same thing I must manually write $. Example

// Notice I use $ here not jQuery like above, this is the only way to get it to work!
; $ = global.jQuery = require("c:\\wamp\\www\\mysite\\app\\client\\requires\\jquery\\js\\jquery.js");
/* ========================================================================
 * Bootstrap: affix.js v3.1.1
 * 
 * ========================================================================
 * Copyright 2011-2014 Twitter, Inc.
 * Licensed under MIT ()
 * ======================================================================== */

So I am trying to figure out how to do this? I downloaded bootstrap-sass via bower and added the bootstrap javascript into a shim.

A few things have me confused, the bootstrap.js file looks like this.

//= require bootstrap/affix
//= require bootstrap/alert
//= require bootstrap/button
//= require bootstrap/carousel
//= require bootstrap/collapse
//= require bootstrap/dropdown
//= require bootstrap/tab
//= require bootstrap/transition
//= require bootstrap/scrollspy
//= require bootstrap/modal
//= require bootstrap/tooltip
//= require bootstrap/popover

This is kind of self explanatory, but still confusing at the same time, do I leave it mented like that? When I add to the bootstrap shim do I include just the bootstrap.js file, or should I link to all the ones I need?

Just to save myself from hacking away (which I will be doing in the meantime), I'd like to try to get some information on how to include bootstrap.js into browserify.

Edit: I think I might just have to concat all the files I need and include that script, because when I browserify the bootstrap.js I just get the above.

I'll try without the ments, then if that fails I'll concat all the scripts into one file and see what happens :)

Edit: Hmm looks like the concat theory works! The only thing is jQuery, take a look.

; jQuery = global.jQuery = require("c:\\wamp\\www\\mysite\\app\\client\\requires\\jquery\\js\\jquery.js");
/* ========================================================================
 * Bootstrap: affix.js v3.1.1
 * http://getbootstrap./javascript/#affix
 * ========================================================================
 * Copyright 2011-2014 Twitter, Inc.
 * Licensed under MIT (https://github./twbs/bootstrap/blob/master/LICENSE)
 * ======================================================================== */

This is my piled browserify code, the only way to get it to work when I call a bootstrap function say for example $('body').modal('toggle') I have to change the jQuery above to $ manually.

I tried using both inside my shim but still same thing I must manually write $. Example

// Notice I use $ here not jQuery like above, this is the only way to get it to work!
; $ = global.jQuery = require("c:\\wamp\\www\\mysite\\app\\client\\requires\\jquery\\js\\jquery.js");
/* ========================================================================
 * Bootstrap: affix.js v3.1.1
 * http://getbootstrap./javascript/#affix
 * ========================================================================
 * Copyright 2011-2014 Twitter, Inc.
 * Licensed under MIT (https://github./twbs/bootstrap/blob/master/LICENSE)
 * ======================================================================== */
Share Improve this question edited Mar 20, 2015 at 17:52 Chrissi 3493 silver badges15 bronze badges asked Apr 9, 2014 at 14:00 Michael Joseph AubryMichael Joseph Aubry 13.5k16 gold badges76 silver badges140 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 12

This answer is by the original questioner. It was posted as an edit to the question. I moved it here, where the answers go.

I repiled and it looks like it's working now, make sure inside your shim you use $

"bootstrap": {
    "exports": "bootstrap",
    "depends": {
        "jquery": "$"
    }
},

Another solution is to use Webpack, which has a script-loader to load jQuery at the global context.

发布评论

评论列表(0)

  1. 暂无评论