我.submit()为表单提交设置了一个事件.我在页面上也有多个表单,但这个例子只有一个.我想知道在没有.click()向每个提交事件应用的情况下点击了哪个提交按钮.
这是设置:
<html>
<head>
<title>jQuery research: forms</title>
<script type='text/javascript' src='../jquery-1.5.2.min.js'></script>
<script type='text/javascript' language='javascript'>
$(document).ready(function(){
$('form[name="testform"]').submit( function(event){ process_form_submission(event); } );
});
function process_form_submission( event ) {
event.preventDefault();
//var target = $(event.target);
var me = event.currentTarget;
var data = me.data.value;
var which_button = '?'; // <-- this is what I want to know
alert( 'data: ' + data + ', button: ' + which_button );
}
</script>
</head>
<body>
<h2>Here's my form:</h2>
<form action='nothing' method='post' name='testform'>
<input type='hidden' …Run Code Online (Sandbox Code Playgroud) 我正在通过自制软件安装星舰,但出现此错误:
Permission denied @ apply2files - /usr/local/lib/node_modules/expo-cli/node_modules/extglob/lib/.DS_Store
Run Code Online (Sandbox Code Playgroud)
修复此错误的任何解决方案?
谢谢。
我正在尝试使用jQuery validate插件来确认我的密码输入.
但是,我不希望它成为必填字段.
只要用户想要更改密码,他们就需要确认密码.
如果不是,则不应验证这两个字段.
jQuery('.validatedForm').validate({
rules: {
password: {
required: true,
minlength: 5
},
password_confirm: {
required: true,
minlength: 5,
equalTo: "#password"
}
}
});
Run Code Online (Sandbox Code Playgroud)
这是完美的,但同样,这两个领域都是必需的.
我希望有这个可选项,以防有人想要更改例如他们的电子邮件或用户名并单独保留密码.
我只是想知道并且在将config.cache_classes设置为true时没有找到模型类(ActiveRecord)中缓存的内容的明确响应?
有人可以告诉我或指出我没找到的文件吗?
谢谢
TL; DR:这个问题在https://github.com/skensell/SO-question-example有自己的示例应用程序,您可以使用它自行调试.我已经在这个问题上提了一次赏金,但我不相信(或者我不明白)最重要的回答者的推理.我将再次给予此奖励,因为这让我感到非常沮丧.
原始问题
我有一个User像这样的关联的模型:
has_many :avatars, -> { order([:sort_order => :asc,:created_at => :asc])}
Run Code Online (Sandbox Code Playgroud)
我有一个端点,它执行搜索用户并设置@users视图使用的变量.这是我在调试器中找到的怪异部分:
@users.first.avatars[0..2].map(&:id)
# => [2546, 2547, 2548]
# This is the correct order.
@users.to_a.first.avatars[0..2].map(&:id)
# => [2548, 2546, 2547]
# Wrong order.
Run Code Online (Sandbox Code Playgroud)
这里发生了什么?
唯一的区别是to_a.我甚至试图忽略它to_a,但我认为它被jbuilder隐含地调用,因为我将它设置为json数组.
也许我正在搜索的方式User与它有关?我正在使用几个包含和连接.
UPDATE
在这里,我可以向您展示rails控制台中这种奇怪行为的简单示例.似乎包括..参考是罪犯,但我不明白为什么或如何.
User.order(id: :desc)
.includes(:avatars, :industries)
.where(industries: {id: [5]})
.references(:industries)
.limit(5).to_a.second.avatars.map(&:id)
# => [2751, 2748, 2749]
# Wrong order.
User.order(id: :desc)
.includes(:avatars, :industries)
.where(industries: {id: [5]})
.references(:industries)
.limit(5).second.avatars.map(&:id)
# …Run Code Online (Sandbox Code Playgroud) 我正在读J.Morgan的一本书黄瓜和奶酪,我遇到了rails puppy app的问题.也就是说,当我执行rails时,我收到以下错误 -
/usr/local/lib/ruby/gems/2.2.0/gems/activesupport-3.2.1/lib/active_support/values/time_zone.rb:268: warning: circular argument reference - now
/usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'coffee-rails'. (Bundler::GemRequireError)
from /usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `each'
from /usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:72:in `block in require'
from /usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `each'
from /usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:61:in `require'
from /usr/local/lib/ruby/gems/2.2.0/gems/bundler-1.11.2/lib/bundler.rb:99:in `require'
from /home/iza/puppies/config/application.rb:7:in `<top (required)>'
from /usr/local/lib/ruby/gems/2.2.0/gems/railties-3.2.1/lib/rails/commands.rb:53:in `require'
from /usr/local/lib/ruby/gems/2.2.0/gems/railties-3.2.1/lib/rails/commands.rb:53:in `block in <top (required)>'
from /usr/local/lib/ruby/gems/2.2.0/gems/railties-3.2.1/lib/rails/commands.rb:50:in `tap'
from /usr/local/lib/ruby/gems/2.2.0/gems/railties-3.2.1/lib/rails/commands.rb:50:in `<top (required)>'
from …Run Code Online (Sandbox Code Playgroud) 我在Ubuntu上安装Jekyll时遇到了一些问题.以下是我的一些版本:
trevor~$ ruby -v
ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux]
trevor~$ gem -v
2.5.1
trevor~$ rvm -v
rvm 1.26.11 (latest) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试安装Jekyll时,我收到以下错误:
trevor~$ gem install jekyll
Building native extensions. This could take a while...
ERROR: Error installing jekyll:
ERROR: Failed to build gem native extension.
current directory: /home/trevor/.rvm/gems/ruby-2.2.4/gems/ffi-1.9.10/ext/ffi_c
/home/trevor/.rvm/rubies/ruby-2.2.4/bin/ruby -r ./siteconf20151229-11854-1czjp2r.rb extconf.rb
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check …Run Code Online (Sandbox Code Playgroud) 我在部署网站时遇到问题AWS.
Gem::LoadError: You have already activated rake 10.4.2, but your Gemfile requires rake 10.5.0. Prepending `bundle exec` to your command may solve this.
/var/app/ondeck/config/boot.rb:3:in `<top (required)>'
/var/app/ondeck/config/application.rb:1:in `<top (required)>'
/var/app/ondeck/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- bundler/setup
/var/app/ondeck/config/boot.rb:3:in `<top (required)>'
/var/app/ondeck/config/application.rb:1:in `<top (required)>'
/var/app/ondeck/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)
(ElasticBeanstalk::ExternalInvocationError)
Run Code Online (Sandbox Code Playgroud)
而当我这样做时,gem list rake它给了我
*** LOCAL GEMS ***
airbrake (4.3.1)
rake (10.5.0, 10.4.2)
Run Code Online (Sandbox Code Playgroud)
我想只有一个版本,当我做bundle exec gem uninstall rake -v …
我的HTML文件:
<html>
<head>
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/scripts.js"></script>
<link rel="stylesheet" type="text/css" href="style.css" />
<title>
Login
</title>
</head>
<body>
<div class=loginForm>
<p>Worker-ID:<input type=text id=workerID name=workerID /></p>
<p>Password:<input type=password id=workerPassword name=workerPassword /></p>
<input type=submit id=submitLogin name=submitLogin value="Log in"/>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我的scripts.js:
$('#workerID').keyup(function() {
alert('key up');
);
Run Code Online (Sandbox Code Playgroud)
它根本不起作用.我尝试了所有空间,一个字母,数字.警报未显示.哪里出错了?
我已经创建了一个示例应用程序,它将html表转换为JSON.问题是JSON没有重复值,我想从JSON中删除最后两列.
我生成的JSON如下所示
[
{
"Person Name":"Smith",
"Score":"disqualified",
"Price":"150",
"Tax":"41"
},
{
"Person Name":"Jackson",
"Score":"94",
"Price":"250",
"Tax":"81"
},
{
"Person Name":"Doe",
"Score":"80",
"Price":"950",
"Tax":"412"
},
{
"Person Name":"Johnson",
"Score":"67",
"Price":"750",
"Tax":"941"
}
]
Run Code Online (Sandbox Code Playgroud)
但我期望的JSON就像
[
{
"Person Name":"Jill",
"Person Name":"Smith",
"Score":"disqualified"
},
{
"Person Name":"Eve",
"Person Name":"Smith",
"Score":"94"
},
{
"Person Name":"John",
"Person Name":"Smith",
"Score":"80"
},
{
"Person Name":"Adam",
"Person Name":"Smith",
"Score":"67"
}
]
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我如何从表中生成上述JSON
我的代码如下所示.
HTML代码
<table id='example-table'>
<thead>
<tr>
<th>Person Name</th>
<th>Person Name</th>
<th data-override="Score">Points</th>
<th>Price</th>
<th>Tax</th>
</tr>
</thead> …Run Code Online (Sandbox Code Playgroud)