开发者

Google App Engine "Multiline" and JavaScript array problem

How do I convert HTML textarea (multiline) to support db.StringProperty() (without the multiline)?

I have try string.replace("\n", "<br>") but the problem is when I insert this to javascript ar开发者_Go百科ray it give me problem.

My code as following:

class Anything(db.Model):
 Str_A = db.StringProperty()
...

anything = Anything.all()

template_values = { 'anything ': anything }
path = os.path.join(os.path.dirname(__file__), 'main.html')
self.response.out.write(template.render(path, template_values))

In the Javascript

var Str_A = [];
{% for a in anything %}
 Str_A.push("{{ anything.Str_A }}");  /* This line problem */
{% endfor %}


You could use db.TextProperty() which supports multi-line text by default, or db.StringProperty(multiline=True) if you need to search or sort on the Str_A property (db.TextProperty is not indexed).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜