Button调用的模式对话框:单击按钮时,将触发事件,结果事件引用e.relatedTarget未定义.那么,如何从处理程序中获取调用按钮?e似乎不包含对调用按钮的任何引用.
<!-- Button trigger modal -->
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
jQuery的:
$('#myModal').on('show.bs.modal', function (e) {
console.log(e.relatedTarget) // do something...
})
Run Code Online (Sandbox Code Playgroud)
我正在command not found...使用我在 package.json 中定义的 bin模块。为什么? 我认为它应该自动将本地命令映射到路径中。
在我的模块的 package.json 中:
"bin": {
"testme": "./misc/testme"
},
Run Code Online (Sandbox Code Playgroud)
./misc/testme 脚本:
#!/usr/bin/env node
console.log("this is a test");
Run Code Online (Sandbox Code Playgroud)
它出现在node_modules/.bin目录中
$ ls node_modules/.bin
acorn escodegen gulp kue-dashboard ncp semver stylus
cake esgenerate gzip-size lessc nopt shjs testme
cleancss esparse handlebars make-plural pretty-bytes sshpk-conv uglifyjs
coffee esvalidate image-size messageformat rc sshpk-sign user-home
dateformat express jade mime retrieve-arguments sshpk-verify uuid
dot-object geojsonhint jsonlint mkdirp rimraf strip-indent watchr
errno grunt js-yaml mustache sails strip-json-comments which
Run Code Online (Sandbox Code Playgroud)
但是, …
我似乎无法使用npm install更新npm:
$ npm -v
5.6.0
$ sudo npm install -g npm@latest
/usr/bin/npm -> /usr/lib/node_modules/npm/bin/npm-cli.js
/usr/bin/npx -> /usr/lib/node_modules/npm/bin/npx-cli.js
+ npm@5.7.1
updated 1 package in 11.905s
$ npm -v
5.6.0
Run Code Online (Sandbox Code Playgroud) node.js ×2
npm ×2
dialog ×1
events ×1
fuelux ×1
modal-dialog ×1
npm-install ×1
package.json ×1