我在我的RethinkDB数据库中存储来自contenteditable标记的原始html.现在我想在检索后显示内容.
html.eex
<div id="contentEditableText">
<%= for %{"contentText" => contentText} <- @contentText.data do %>
<div><%= "#{contentText}" %></div>
<% end %>
</div>
Run Code Online (Sandbox Code Playgroud)
我可以成功检索它,但它显示原始的html本身.
我们希望使用我们的内容可编辑,利用router.ex中生成的以下路由:
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :put_secure_browser_headers
end
pipeline :api do
plug :accepts, ["json"]
end
scope "/", TextEditor do
pipe_through :browser # Use the default browser stack
get "/", PageController, :index
resources "/posts", PostController
end
Run Code Online (Sandbox Code Playgroud)
和控制器功能,即创建:
def create(conn, %{"post" => post_params}) do
changeset = Post.changeset(%Post{}, post_params)
case Repo.insert(changeset) do
{:ok, _post} ->
conn
|> put_flash(:info, "Post created successfully.")
|> redirect(to: post_path(conn, :index))
{:error, changeset} ->
render(conn, "new.html", changeset: changeset)
end
end
Run Code Online (Sandbox Code Playgroud)
但是我们不想使用生成的表单,然后我们尝试使用div和jquery方法$ .post来测试它:
<div …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用addict包在我的项目中进行身份验证,但每当我尝试执行操作(注册,登录...)时,我的POST都会收到CrossDomain错误.
我已经尝试添加cors_plug包来解决这些问题并添加
<input type="hidden" name="_csrf_token" value="<%= get_csrf_token %>">
Run Code Online (Sandbox Code Playgroud)
到我的index.html.eex模板页面,我仍然在我的浏览器控制台上得到这个:
POST http://localhost:4000/register 403 (Forbidden)
n.ajaxTransport.k.cors.a.crossDomain.send @ jquery-2.1.4.min.js:4
n.extend.ajax @ jquery-2.1.4.min.js:4
n.each.n.(anonymous function) @ jquery-2.1.4.min.js:4
(anonymous function) @ socket.js:62
n.event.dispatch @ jquery-2.1.4.min.js:3
n.event.add.r.handle @ jquery-2.1.4.min.js:3
XHR finished loading: POST "http://localhost:4000/register".
n.ajaxTransport.k.cors.a.crossDomain.send @ jquery-2.1.4.min.js:4
n.extend.ajax @ jquery-2.1.4.min.js:4n.each.n.(anonymous function) @ jquery-2.1.4.min.js:4
(anonymous function) @ socket.js:62n.event.dispatch @ jquery-2.1.4.min.js:3
n.event.add.r.handle @ jquery-2.1.4.min.js:3
Run Code Online (Sandbox Code Playgroud)
我的javascript代码与addict示例相同,只是我没有将它作为脚本放在我的模板中(当我尝试时甚至没有调用代码).我把它放在底部priv/static/js/app.js.js代码如下:
$('#btn-register').click(function() {
var email = $('#txt-register-email').val();
var username = $('#txt-register-username').val();
var password = $('#txt-register-password').val();
$.post('/register', …Run Code Online (Sandbox Code Playgroud) 当我将事件拖到另一个时间段时,我的全日历会在视觉上复制事件。我已将我的代码简化为 eventDrop 以隔离问题,但我无法理解该问题。如果我将事件存储到我的 localStorage 中,我不会在存储中得到重复项,并且当我重新加载页面时,重复项就会消失。这意味着问题只是视觉上的,并且是完整日历本身。然而,这显然是一个大问题,因为我不想重新加载页面:我想留在当前视图中更改我需要的内容。
这是我的 eventDrop 代码:
eventDrop: function(event, delta, revertFunc, jsEvent, ui, view) {
if (!confirm("Are you sure you want to change " + event.title + " ?")) {
/*If the user cancels the change, the event returns to its original position. Otherwise it saves the event.*/
revertFunc(); /*Revert changes using the predefined function revertFunc of fullCalendar.*/
$("#calendar").fullCalendar("refetchEvents");
/*FullCalendar Method to refetch events from all sources and rerender them on the screen.*/
} else {
updateConfirm(event); /*Use the …Run Code Online (Sandbox Code Playgroud) 我正在提取一个包含4个对象的数组,每个对象在我的Angular项目中都有一个数组,来自我的kendo图表数据源.
每个子对象内的数据大小不一,但它始终包含时间戳和1-5个值字段.
我需要将此数组导出到Excel文件(.xls或.xlsx NOT CSV).
到目前为止,我设法将JSON作为文件单独下载(.json和unformatted .xls).
我希望每个对象都是一本书,并且在那本书中有一个格式在第一列中有时间戳,在另一列中有值1,依此类推.列的标题应该是timestamp,value1 name等(我根据用户的喜好在ui上翻译它们).
如何使用angular构建这种格式化的.xls文件?我不知道这个特别好的库,关于如何在Angular中使用它很清楚.
我怎样才能在凤凰城使用语言包?我正试图在网页上进行国际化.我已经将包添加到mix.exs并mix deps.get成功运行.
现在,我不知道在哪个文件夹中写入包的模块文件的位置,以及它应该是ex或exs扩展名,如用例(fr.exs)中的其他国家/地区语言文件.
此外,在编写模块后,我将如何将其应用于HTML标记?
elixir ×4
javascript ×2
jquery ×2
ajax ×1
angularjs ×1
excel ×1
fullcalendar ×1
html ×1
json ×1