小编Tay*_*kes的帖子

Flux/React复合可重复使用组件

我想做这样的事情

var App = React.createClass({
    render: function() {
        return (
            <CountryAutoComplete />
        )
    }
});
Run Code Online (Sandbox Code Playgroud)

不同的应用

var App2 = React.createClass({
    render: function() {
        return (
            <CountryAutoComplete />
        )
    }
});
Run Code Online (Sandbox Code Playgroud)

这是一个简单的自动完成(不是整个文件)

var AutoComplete = React.createClass({
    componentDidMount: function() {
        $(this.getDOMNode()).typeahead(this.props);
    },
    render: function() {
        return (
            <input type="text" class="typeahead" onChange={this.props.onChange} />
        );
    }
});
Run Code Online (Sandbox Code Playgroud)

CountryAutoComplete将是这样的自包含.

var CountryAutoComplete = React.createClass({
    search: function(country, process) {
        // Make an ajax call and return the data. No other components needed
        $.ajax({
            url: '/country' + '?search=' …
Run Code Online (Sandbox Code Playgroud)

reactjs reactjs-flux

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

在javascript中捕获X-Frame-Options错误

从其他域加载iframe时是否有任何方法可以捕获错误.这是jsfiddle中的一个例子.http://jsfiddle.net/2Udzu/.如果收到错误,我需要显示一条消息.

这是我想做的,但它不起作用

$('iframe')[0].onerror = function(e) {
   alert('There was an error loading the iFrame');
}
Run Code Online (Sandbox Code Playgroud)

有人有主意吗?

html javascript error-handling dom-events

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