Dojo数字主题渲染form_for提交无文本输入
我有以下 Rails form_for 定义。正如您在屏幕截图中看到的,它没有呈现提交输入的“登录”文本。我还包含了生成的 HTML。
<h2>Sign in</h2>
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name), :dojoType => "dijit.form.Form") do |f| %>
<p><%= f.label :login %><br />
<%= f.text_field :login, {:dojoType => "dijit.form.TextBox"} %></p>
<p><%= f.label :password %><br />
<%= f.password_field :password, {:dojoType => "dijit.form.TextBox"} %></p>
<% if devise_mapping.rememberable? -%>
<p><%= f.check_box :remember_me, {:dojoType => "dijit.form.CheckBox"} %> <%= f.label :remember_me %></p>
<% end -%>
<p><%= f.submit "Sign in", {:dojoType => "dijit.form.Button"} %></p>
<% end %>
<%= render :partial => "devise/shared/links" %>
HTML
<span class="dijit dijitReset dijitInline dijitButton" dir="ltr" widgetid="user_submit"><span class="dijitReset dijitInline dijitButtonNode" dojoattachevent="ondijitclick:_onButtonClick">
<span class="dijitReset dijitStretch dijitButtonContents" dojoattachpoint="titleNode,focusNode" wairole="button" waistate="labelledby-user_submit_label" role="button" aria-labelledby="user_submit_label" id="user_submit" tabindex="0" style="-webkit-user-select: none; ">
<span class="dijitReset dijitInline dijitIcon" dojoattachpoint="iconNode"></span><span class="dijitReset dijitToggleButtonIconChar">●</span>
<span class="dijitReset dijitInline dijitButtonText" id="user_submit_label" dojoattachpoint="containerNode"></span>
</span>
</span>
<input name="commit" type="submit" value="Sign In" class="dijitOffScreen" dojoattachpoint="valueNode">
</span>
I have the following Rails form_for definition. As you can see in the screen shot, it is not rendering the "Sign In" text for the Submit input. I have also included the resulting HTML.
<h2>Sign in</h2>
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name), :dojoType => "dijit.form.Form") do |f| %>
<p><%= f.label :login %><br />
<%= f.text_field :login, {:dojoType => "dijit.form.TextBox"} %></p>
<p><%= f.label :password %><br />
<%= f.password_field :password, {:dojoType => "dijit.form.TextBox"} %></p>
<% if devise_mapping.rememberable? -%>
<p><%= f.check_box :remember_me, {:dojoType => "dijit.form.CheckBox"} %> <%= f.label :remember_me %></p>
<% end -%>
<p><%= f.submit "Sign in", {:dojoType => "dijit.form.Button"} %></p>
<% end %>
<%= render :partial => "devise/shared/links" %>
HTML
<span class="dijit dijitReset dijitInline dijitButton" dir="ltr" widgetid="user_submit"><span class="dijitReset dijitInline dijitButtonNode" dojoattachevent="ondijitclick:_onButtonClick">
<span class="dijitReset dijitStretch dijitButtonContents" dojoattachpoint="titleNode,focusNode" wairole="button" waistate="labelledby-user_submit_label" role="button" aria-labelledby="user_submit_label" id="user_submit" tabindex="0" style="-webkit-user-select: none; ">
<span class="dijitReset dijitInline dijitIcon" dojoattachpoint="iconNode"></span><span class="dijitReset dijitToggleButtonIconChar">●</span>
<span class="dijitReset dijitInline dijitButtonText" id="user_submit_label" dojoattachpoint="containerNode"></span>
</span>
</span>
<input name="commit" type="submit" value="Sign In" class="dijitOffScreen" dojoattachpoint="valueNode">
</span>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的 ERB 代码是正确的,工作正常。
看来你在主要布局上遇到了麻烦。
您必须添加 dojo 脚本定义部分。
我建议您为这个概念创建一个干净的新布局。
我的头在 dojo.html.erb
<%= stylesheet_link_tag "默认" %>
<%= csrf_meta_tag %>
<%= javascript_include_tag 'http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js' , :djconfig => "parseOnLoad: true"%>
Your ERB code is correct, it is working fine.
It seems you have trouble on main layout.
You must add your dojo script definition section.
I recommend you to create a clean new layout for this concept.
My head is on dojo.html.erb
<%= stylesheet_link_tag "default" %>
<%= csrf_meta_tag %>
<%= javascript_include_tag 'http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js' , :djconfig => "parseOnLoad: true"%>
问题很简单,如果你检查dojo上的示例,按钮是按钮类型,但rails产生输入类型,所以它不起作用。
您可以在 erb 文件上写入,
它正在工作,
或者您可以在 application_helper.rb 上编写帮助程序脚本
Problem is simple, if you check samples on dojo, button is button type, but rails produces input type, so it is not working.
You can write on erb file,
it is working,
or you can write your helper script on application_helper.rb