Ruby on Rails,Low Pro和JQuery(通过JRails) [英] Ruby on Rails, Low Pro, and JQuery (through JRails)
问题描述
我在Ruby on Rails上使用 JRails ,以便我可以简单地使用jQuery,因为我更加熟悉它。我也尝试使用低级专业人士提交一些我的表单远程。
我目前遇到一个有趣的问题,让我难住。我已经将以下内容添加到我的 application.js
文件中,并且我知道这些工作正常,因为我看到了返回的响应(使用Firefox中的Firebug):
$。ajaxSetup({
dataType:script
});
$(function(){
$('a.remote')。attach(Remote.Link);
$('form.remote')。attach(Remote .Form);
});
我只需要添加 class =remote
给我的链接和我的表格,一切都很好。 dataType:script
部分确保它在返回的响应文本上执行 eval()
,以便它可以正确更新页面。
所以,我有一个简单的链接来创建一个新的货件。在我的 new.js.rjs
文件中,我有以下内容:
page.insert_html:bottom,'#shipments_table',
:partial => 'test',:locals => {:出货=> @shipment}
如果我用 page.visual_effect替换它:fade,' #shipments_table'
它就像你期望的那样。如果我的 _test.html.erb
文件非常简单,它也可以。问题是当我尝试向我的partial中添加< form>
时。取决于< form>
标签的位置,会出现不同的问题。例如,这
< tr>
< form>
< td>一些文字< / td>
< / form>
< / tr>
和
<形式>
< tr>
< td>一些文字< / td>
< / tr>
< / form>
完全不显示。这
< form>< / form>
< tr>
< td>一些文字< / td>
< / tr>
会显示一些文字
,但它失去了我所有的格式。而这
< tr>
< td>一些文字< / td>
< / tr>
< form>< / form>
完全符合我的需求(从视觉上讲)。然而,这个明显的缺点是我无法将表单输入放到表格列中,这基本上使得整个过程无用。我可以通过简单地把它们全部放在< div>
或类似的东西里面的一行来解决这个问题,但我更喜欢所有东西都是对齐的。
任何有关如何解决这个难题的想法都将不胜感激: - )
< form>
应放在< td>
内,或者将< table>
: < form>< table />< /形式>
I am using JRails with Ruby on Rails so that I can simply use jQuery since I am more familiar with it. I am also attempting to use Low Pro to submit some of my forms remotely.
I am currently running into an interesting problem that has me stumped. I have added the following to my application.js
file and I know that these are working correctly because I am seeing the response returned (using Firebug in Firefox):
$.ajaxSetup({
dataType: "script"
});
$(function() {
$('a.remote').attach(Remote.Link);
$('form.remote').attach(Remote.Form);
});
All I have to do is add class="remote"
to my links and my forms and everything works great. The dataType: "script"
part makes sure that it does an eval()
on the returned response text so that it can update the page correctly.
So, I have a simple link that creates a new shipment. In my new.js.rjs
file I have the following:
page.insert_html :bottom, '#shipments_table',
:partial => 'test', :locals => { :shipment => @shipment }
If I replace this with page.visual_effect :fade, '#shipments_table'
it does that as you would expect. If my _test.html.erb
file is fairly simple, it also works. The problem is when I attempt to add a <form>
to my partial. Different problems arise depending upon the placement of the <form>
tags. For example, this
<tr>
<form>
<td>Some Text</td>
</form>
</tr>
and this
<form>
<tr>
<td>Some Text</td>
</tr>
</form>
make absolutely nothing appear. This
<form></form>
<tr>
<td>Some Text</td>
</tr>
will make Some Text
appear, but it loses all of my formatting. And this
<tr>
<td>Some Text</td>
</tr>
<form></form>
works exactly how I need (visually speaking). However, the obvious downside to this is that I can't put my form inputs into the table columns, which basically makes the whole process useless. I can probably work around this by simply putting them all on one line inside of a <div>
or something similar, but I would prefer that everything be aligned.
Any ideas as to how to solve this conundrum would be greatly appreciated :-)
<form>
should only be placed inside the <td>
or wrap the <table>
:
<form><table/></form>
这篇关于Ruby on Rails,Low Pro和JQuery(通过JRails)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!