我有这样的数据结构:

我试着通过$ .ajax将它发送到服务器:
$.ajax({
type: 'POST',
data: post_obj, //this is my json data
dataType: 'json',
url: '',
success: function(e){
console.log(e);
}
});
Run Code Online (Sandbox Code Playgroud)
我希望通过烧瓶在服务器中获取它:title = request.form['title'] 工作正常!
但我怎么得到content?
request.form.getlist('content') 不起作用.
这是firebug中的帖子数据:

非常感谢:D
我不想使用url_for('static',file_name ='foo.jpg')来获取模板中的静态文件.
如何以这种方式获取静态文件:
<img src="/pic/foo.jpg" />
Run Code Online (Sandbox Code Playgroud)
谢谢
我有一个如下的答案列表:

每个列表项都是骨干模型.
{
title: 'answer title...',
content: 'answer content...',
voteStatus: 'up'
}
Run Code Online (Sandbox Code Playgroud)
当我点击向上投票或向下投票时,模型voteStatus将会更改,并且此答案项目将重新呈现.
如果答案内容中有图片,图片也会重新渲染,但这不是我想要的.
当我改变时,我怎么能重新渲染投票按钮voteStatus?
我有一个这样的评论框:

我已将所有操作绑定到CommentBox组件,有一个decComment操作来处理Delete每个注释中的事件.
每次当我点击delete按钮,Comment我需要通过commentId的Comment到CommentList到CommentBox,然后CommentBox更新注释数据,去除评论数据评论和重新呈现评论列表.
这是一些代码:
var Comment = React.createClass({
handleDel: function() {
var cid = this.props.cid;
this.props.onDel(cid);
return false;
},
render: function() {
return (
<div key={this.props.cid}>
<a onClick={this.handleDel}>Del</a>
</div>
);
}
});
var CommentList = React.createClass({
handleDel: function(cid) {
this.props.onDel(cid);
},
render: function() {
var commentNodes = this.props.data.map(function(c) {
return <Comment cid={c.id} onDel={this.handleDel} />
}.bind(this));
return (
<div className="comments">
{commentNodes}
</div>
)
}
}); …Run Code Online (Sandbox Code Playgroud) 像这样的代码:
var Try = React.createClass({displayName: "Try",
getInitialState: function() {
return {
int: 'x'
};
},
ck: function() {
this.setState({int: 1});
console.log(this.state.int);
},
render: function() {
return (
React.createElement("div", {onClick: this.ck}, "Hello")
);
}
});
React.render(React.createElement(Try, null), $('body')[0]);
Run Code Online (Sandbox Code Playgroud)
在线试试在这里:http://codepen.io/rlog/pen/qdvVEK/
当我点击Hellodiv.
第一次登录x,为什么不1呢?
我有一个按钮,当我点击这个按钮时,我想渲染一个div并附加到它body.
当我再次单击此按钮时,div将呈现一个新的.
我想:我点击按钮多少次,div渲染多少次.
以下代码只能呈现一个div:(jsFiddle:http://jsfiddle.net/pw4yq/)
var $tool = document.getElementById('tool');
var $main = document.getElementById('main');
var partBox = React.createClass({displayName: 'partBox',
render: function(){
return (
React.DOM.div({className:"box"}, "HELLO! ", this.props.ts)
)
}
});
var createBoxBtn = React.createClass({displayName: 'createBoxBtn',
createBox: function(){
var timeStamp = new Date().getTime();
React.renderComponent(partBox( {ts:timeStamp} ), $main);
},
render: function(){
return (
React.DOM.button( {onClick:this.createBox}, "createBox")
)
}
});
React.renderComponent(createBoxBtn(null ), $tool);
Run Code Online (Sandbox Code Playgroud) javascript ×3
reactjs ×3
flask ×2
python ×2
backbone.js ×1
html ×1
jinja2 ×1
json ×1
model ×1
post ×1
rerender ×1
static-files ×1
templates ×1