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">●&lt;/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>
4

2 回答 2

1

您的 ERB 代码是正确的,它工作正常。看来您在主要布局上遇到了麻烦。您必须添加您的 dojo 脚本定义部分。我建议您为此概念创建一个干净的新布局。我的头在 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: 真"%>

于 2011-02-18T18:58:04.360 回答
0

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

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

它正在工作,或者您可以在 application_helper.rb 上编写您的帮助脚本

于 2011-02-19T19:44:56.603 回答