我在Sublime Text文件中选择了几个字符串,我想将它们全部转换为小写。如何将它们全部转换为Sublime Text中的小写字母?
最近我发现了最简单易懂的处理方法:
$(document).on 'ready page:load', ->
# Actions to do
要么
$(document).on('ready page:load', function () {
// Actions to do
});
编辑
如果你有委托的事件绑定到document,确保你把它们附加在ready函数之外,否则它们将在每个page:load事件(导致相同的函数被多次运行)上反弹。例如,如果你有任何这样的电话:
$(document).on 'ready page:load', ->
...
$(document).on 'click', '.button', ->
...
...
把它们从ready功能中拿出来,就像这样:
$(document).on 'ready page:load', ->
...
...
$(document).on 'click', '.button', ->
...
绑定的委托事件document不需要绑定在ready事件上。
是我做的... CoffeeScript:
ready = ->
...your coffeescript goes here...
$(document).ready(ready)
$(document).on('page:load', ready)
最后一行监听页面加载,这是turbo链接将触发的。
编辑 ...添加Javascript版本(每个请求):
var ready;
ready = function() {
...your javascript goes here...
};
$(document).ready(ready);
$(document).on('page:load', ready);
编辑2 ...对于Rails 5(Turbolinks 5)page:load变得turbolinks:load甚至会在初始加载时被解雇。所以我们可以做到以下几点:
$(document).on('turbolinks:load', function() {
...your javascript goes here...
});
相似问题