fixed select2 issues
This commit is contained in:
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 |
@ -1,6 +1,6 @@
|
|||||||
@import 'nib'
|
@import 'nib'
|
||||||
|
|
||||||
@require 'select2/select2.css'
|
@require 'select2/dist/css/select2.css'
|
||||||
|
|
||||||
@require 'common'
|
@require 'common'
|
||||||
@require 'modal'
|
@require 'modal'
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Vendor CSS
|
// Vendor CSS
|
||||||
@require 'select2/select2.css'
|
@require 'select2/dist/css/select2.css'
|
||||||
@require 'spectrum-colorpicker/spectrum.css'
|
@require 'spectrum-colorpicker/spectrum.css'
|
||||||
|
|
||||||
// Bootstrapping
|
// Bootstrapping
|
||||||
|
@ -10,32 +10,34 @@ function(
|
|||||||
var Selection = React.createClass({
|
var Selection = React.createClass({
|
||||||
getInitialState: function() {
|
getInitialState: function() {
|
||||||
return {
|
return {
|
||||||
items: []
|
items: [],
|
||||||
|
initialized: false
|
||||||
}
|
}
|
||||||
},
|
|
||||||
componentWillMount: function() {
|
|
||||||
|
|
||||||
},
|
},
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
this.loadCachedItems();
|
this.loadCachedItems();
|
||||||
},
|
},
|
||||||
|
componentDidUpdate: function() {
|
||||||
|
this.setupSelect2();
|
||||||
|
},
|
||||||
setupSelect2: function() {
|
setupSelect2: function() {
|
||||||
|
if(this.state.initialized === true) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(this.props.field.select2 && Object.keys(this.props.item).length > 0) {
|
if(this.props.field.select2 && Object.keys(this.props.item).length > 0) {
|
||||||
console.log('do it!');
|
var select2 = jQuery('#'+this.props.field.id).select2({
|
||||||
jQuery('#'+this.props.field.id).select2({
|
width: (this.props.width || '')
|
||||||
width: this.props.field.width
|
});
|
||||||
}).select2(
|
|
||||||
|
select2.on('change', this.handleChange)
|
||||||
|
|
||||||
|
select2.select2(
|
||||||
'val',
|
'val',
|
||||||
this.props.item[this.props.field.name]
|
this.props.item[this.props.field.name]
|
||||||
).on('change', this.handleChange);
|
);
|
||||||
|
|
||||||
// set values
|
this.setState({ initialized: true });
|
||||||
/*jQuery('#'+this.props.field.id).select2(
|
|
||||||
'val',
|
|
||||||
this.props.item[this.props.field.name]
|
|
||||||
);*/
|
|
||||||
|
|
||||||
console.log(this.props.item[this.props.field.name]);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
loadCachedItems: function() {
|
loadCachedItems: function() {
|
||||||
@ -78,8 +80,6 @@ function(
|
|||||||
: null
|
: null
|
||||||
);
|
);
|
||||||
|
|
||||||
this.setupSelect2();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<select
|
<select
|
||||||
id={ this.props.field.id }
|
id={ this.props.field.id }
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
"react-prefixr": "0.1.0",
|
"react-prefixr": "0.1.0",
|
||||||
"react-router": "^1.0.0-rc3",
|
"react-router": "^1.0.0-rc3",
|
||||||
"react-waypoint": "1.0.4",
|
"react-waypoint": "1.0.4",
|
||||||
"select2": "3.5.1",
|
"select2": "^4.0.0",
|
||||||
"spectrum-colorpicker": "^1.6.2",
|
"spectrum-colorpicker": "^1.6.2",
|
||||||
"tinymce": "4.1.10",
|
"tinymce": "4.1.10",
|
||||||
"underscore": "1.8.3"
|
"underscore": "1.8.3"
|
||||||
|
Reference in New Issue
Block a user