如何在.js.haml文件中构建html? [英] How do i build html inside .js.haml file?

查看:153
本文介绍了如何在.js.haml文件中构建html?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何雄辩地在我的ajax调用中返回以下调用?我在append函数中可以有断行等等。

I am wondering how to eloquently return the following call in my ajax call? Where i can have break lines etc inside the append function?

$(".q#{@question_id}.result_to_response")
.html("#{escape_javascript(@resp)}")
.append('<div><a href="#" class="continue_button">Continuez to next question</a></div>');


推荐答案

我的建议只是使用 jQuery模板或smthng类似的。这种方式你很容易生成所有的模板与haml,然后只是追加.tmpl()返回值在html体。

My advice to you is just use jQuery templates or smthng similar for that. This way you easily generate all your templates with haml and then just append .tmpl() return value in html body.

生成内联javascript是一个糟糕的应用程序设计的迹象。

Generating inline javascript is a sign of poor application design.

这篇关于如何在.js.haml文件中构建html?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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