Bootstrap样式的按钮未应用于Phoenix删除链接 [英] Bootstrap styled button not being applied to Phoenix delete link

查看:98
本文介绍了Bootstrap样式的按钮未应用于Phoenix删除链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • Elixir版本:1.3.2
  • 凤凰版本:1.2.1
  • NodeJS版本:4.4.6
  • NPM版本:3.10.6
  • 简版:2.7.4
  • 操作系统:Mac OSX

我正在尝试使用Phoenix的 link创建一个简单的链接辅助功能.

I am trying to create what suppose to be a simple link using Phoenix's link helper function.

<li><%= link "Logout", to: session_path(@conn, :delete, user), method: :delete %></li>

提供

<form action="/logout/1" class="link" method="post">
  <input name="_method" type="hidden" value="delete">
  <input name="_csrf_token" type="hidden" value="VhxiLApJElIS...removed for clarity">
  <a data-submit="parent" href="#" rel="nofollow">Logout</a>
</form> 

该按钮工作正常,用户已注销,但未应用该按钮的样式.见下文:

The button works fine and the user logs out but the styling of the button isn't being applied. See below:

登出"按钮应与主页"按钮对齐并包含悬停效果. 删除注销按钮样式的方法是什么?

The "logout" button should be aligned with and contain hover effects like the "Home" button . What is removing the styling of the logout button?

当用户注销时,样式返回:

When a user logs out the styling returns:

这是有关删除链接功能的其他相关问题.

Here are other related issues on the delete link functionality.

  • Delete link not working phoenix
  • https://github.com/phoenixframework/phoenix/issues/1204
  • https://github.com/phoenixframework/phoenix/issues/1408
  • https://github.com/phoenixframework/phoenix/issues/1319

这是我根据发现的其他问题所尝试的方法:

Here's what I've tried based on the other issues I've found:

  • 运行brunch build-编译成功
  • link功能更改为button
  • run brunch build- compilation succeeds
  • change the link function to button

希望这是足够的信息来获得一些输入.

Hopefully this is enough information to get some input.

推荐答案

delete链接确实会创建一个表单,这是可以预期的.如果您查看生成器创建的内容,则如下所示:

The delete links do create a form and this is expected. If you look at what the generators create, its something like below:

<%= link "Delete", to: schedule_path(@conn, :delete, schedule), method: :delete, data: [confirm: "Are you sure?"], class: "btn btn-danger btn-xs" %>

您不能直接从锚点调用delete或post方法,因此Phoenix为您创建了一个表单.这是一项便利功能,但起初可能会造成混淆.因此,如果表单不起作用,则问题可能出在您的控制器上,而不是表单本身.

You cannot call a delete or post method from a anchor directly, so Phoenix makes a form for you. It's a convenience feature, but can be confusing at first. So if the form is not working the problem may be in your controller not with the form itself.

这篇关于Bootstrap样式的按钮未应用于Phoenix删除链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆