如何将 html5 data- 属性添加到 rails form_tag
我知道您可以为 form_for 标签执行此操作,但它与 form_tag 的渲染方式不同:
<%= form_for(@inventory, :remote => true, :html => { 'data-parsley-validate' => "", "data-parsley-errors-container" => "#inventory_errors" }) do |f| %>
Run Code Online (Sandbox Code Playgroud) 为什么total = total + i比total + = i快得多?这是我多次运行的代码:
var iterations = 1000000;
console.time('Operation total += i');
var total = 0;
for(var i = 0; i < iterations; i++ ){
total += i;
};
console.timeEnd('Operation total += i');
console.time('Operation total = total + i');
var total = 0;
for(var i = 0; i < iterations; i++ ){
total = total + i;
};
console.timeEnd('Operation total = total + i');
Run Code Online (Sandbox Code Playgroud)
以下是一些示例输出: