小编Mil*_*ous的帖子

刷新一个元素,使其新的工具提示显示(在jQuery/Javascript中)

我有一个html元素,它使用bootstrap工具提示在鼠标悬停时显示标题.但是,当您单击此元素时,我正在更改工具提示,但是直到我从中移除鼠标并再次将鼠标悬停在元素上之后,新工具提示才会显示.

我希望在单击所述按钮时立即显示工具提示.我怎样才能做到这一点?有没有办法"刷新",缺乏更好的单词,一个HTML元素?

javascript jquery twitter-bootstrap twitter-bootstrap-tooltip

5
推荐指数
2
解决办法
1万
查看次数

如何正确地将任意路径重新路由到Plug.Static文件的文件?

我正在考虑跳过凤凰城,因为我只打算为React应用程序构建一个演示程序,该应用程序使用一些API路由作为其状态.似乎是一个熟悉底层技术的机会.

我想出了以下内容,但感觉非常"硬编码",我很好奇是否有更优雅的解决方案来实现同样的目标.

defmodule DemoApp.Plug.ServeStatic do
  use Plug.Builder

  @static_opts [at: "/", from: "priv/static"]

  plug :default_index
  plug Plug.Static, @static_opts
  plug :default_404
  plug Plug.Static, Keyword.put(@static_opts, :only, ["error_404.html"])

  # Rewrite / to "index.html" so Plug.Static finds a match
  def default_index(%{request_path: "/"} = conn, _opts) do
    %{conn | :path_info => ["index.html"]}
  end
  def default_index(conn, _), do: conn

  # Rewrite everything that wasn't found to an existing error file
  def default_404(conn, _opts) do
    %{conn | :path_info => ["error_404.html"]}
  end
end
Run Code Online (Sandbox Code Playgroud)

这个想法是让/服务index.html没有重定向,并在找不到某些东西时提供错误文件的内容,而不是最小的响应"404 file …

elixir phoenix-framework

1
推荐指数
1
解决办法
700
查看次数