Dojo数字主题渲染form_for提交无文本输入

发布于 2024-10-17 14:24:14 字数 1991 浏览 1 评论 0原文

我有以下 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" %>

enter image description here

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

破晓 2024-10-24 14:24:14

您的 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"%>

花开半夏魅人心 2024-10-24 14:24:14

问题很简单,如果你检查dojo上的示例,按钮是按钮类型,但rails产生输入类型,所以它不起作用。
您可以在 erb 文件上写入,

<button dojoType="dijit.form.Button" type="button">Click me too!</button>

它正在工作,
或者您可以在 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,

<button dojoType="dijit.form.Button" type="button">Click me too!</button>

it is working,
or you can write your helper script on application_helper.rb

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文