fixed select2 issues

This commit is contained in:
Jonathan Labreuille
2015-10-21 13:45:34 +02:00
parent d4bfb49415
commit d07221846f
7 changed files with 21 additions and 21 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 613 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 845 B

View File

@ -1,6 +1,6 @@
@import 'nib'
@require 'select2/select2.css'
@require 'select2/dist/css/select2.css'
@require 'common'
@require 'modal'

View File

@ -1,5 +1,5 @@
// Vendor CSS
@require 'select2/select2.css'
@require 'select2/dist/css/select2.css'
@require 'spectrum-colorpicker/spectrum.css'
// Bootstrapping

View File

@ -10,32 +10,34 @@ function(
var Selection = React.createClass({
getInitialState: function() {
return {
items: []
items: [],
initialized: false
}
},
componentWillMount: function() {
},
componentDidMount: function() {
this.loadCachedItems();
},
componentDidUpdate: function() {
this.setupSelect2();
},
setupSelect2: function() {
if(this.state.initialized === true) {
return;
}
if(this.props.field.select2 && Object.keys(this.props.item).length > 0) {
console.log('do it!');
jQuery('#'+this.props.field.id).select2({
width: this.props.field.width
}).select2(
var select2 = jQuery('#'+this.props.field.id).select2({
width: (this.props.width || '')
});
select2.on('change', this.handleChange)
select2.select2(
'val',
this.props.item[this.props.field.name]
).on('change', this.handleChange);
);
// set values
/*jQuery('#'+this.props.field.id).select2(
'val',
this.props.item[this.props.field.name]
);*/
console.log(this.props.item[this.props.field.name]);
this.setState({ initialized: true });
}
},
loadCachedItems: function() {
@ -78,8 +80,6 @@ function(
: null
);
this.setupSelect2();
return (
<select
id={ this.props.field.id }

View File

@ -30,7 +30,7 @@
"react-prefixr": "0.1.0",
"react-router": "^1.0.0-rc3",
"react-waypoint": "1.0.4",
"select2": "3.5.1",
"select2": "^4.0.0",
"spectrum-colorpicker": "^1.6.2",
"tinymce": "4.1.10",
"underscore": "1.8.3"