diff --git a/src/element/editable-element.css b/src/element/editable-element.css index 9d9eaf6..f6b09c5 100644 --- a/src/element/editable-element.css +++ b/src/element/editable-element.css @@ -28,3 +28,10 @@ a.editable-click.editable-disabled:hover { /* content: '*'*/ } +/*see https://github.com/vitalets/x-editable/issues/139 */ +.form-horizontal .editable +{ + padding-top: 5px; + display:inline-block; +} + diff --git a/src/inputs/combodate/combodate.js b/src/inputs/combodate/combodate.js index dd835de..a68c3f4 100644 --- a/src/inputs/combodate/combodate.js +++ b/src/inputs/combodate/combodate.js @@ -1,6 +1,6 @@ /** Combodate input - dropdown date and time picker. -Based on [combodate](http://vitalets.github.com/combodate) plugin. To use it you should manually include [momentjs](http://momentjs.com). +Based on [combodate](http://vitalets.github.com/combodate) plugin (included). To use it you should manually include [momentjs](http://momentjs.com). <script src="js/moment.min.js"></script> diff --git a/src/inputs/select2/select2.js b/src/inputs/select2/select2.js index 439a541..1753dbb 100644 --- a/src/inputs/select2/select2.js +++ b/src/inputs/select2/select2.js @@ -6,6 +6,9 @@ You should manually include select2 distributive: <link href="select2/select2.css" rel="stylesheet" type="text/css"></link> <script src="select2/select2.js"></script> +**Note:** currently `ajax` source for select2 is not supported, as it's not possible to load it in closed select2 state. +The solution is to load source manually and assign statically. + @class select2 @extends abstractinput @since 1.4.1 @@ -35,7 +38,7 @@ $(function(){ options.select2 = options.select2 || {}; var that = this, - mixin = { + mixin = { //mixin to select2 options placeholder: options.placeholder }; @@ -50,6 +53,23 @@ $(function(){ //this function can be defaulted in seletc2. See https://github.com/ivaynberg/select2/issues/710 mixin.initSelection = function (element, callback) { + //temp: try update results + /* + if(options.select2 && options.select2.ajax) { + console.log('attached'); + var original = $(element).data('select2').postprocessResults; + console.log(original); + $(element).data('select2').postprocessResults = function(data, initial) { + console.log('postprocess'); + // this.element.triggerHandler('loaded', [data]); + original.apply(this, arguments); + } + + // $(element).on('loaded', function(){console.log('loaded');}); + $(element).data('select2').updateResults(true); + } + */ + var val = that.str2value(element.val()), data = $.fn.editableutils.itemsByValue(val, mixin.data, 'id'); @@ -74,6 +94,19 @@ $(function(){ //apply select2 this.$input.select2(this.options.select2); + //when data is loaded via ajax, we need to know when it's done + if('ajax' in this.options.select2) { + /* + console.log('attached'); + var original = this.$input.data('select2').postprocessResults; + this.$input.data('select2').postprocessResults = function(data, initial) { + this.element.triggerHandler('loaded', [data]); + original.apply(this, arguments); + } + */ + } + + //trigger resize of editableform to re-position container in multi-valued mode if(this.isMultiple) { this.$input.on('change', function() { @@ -84,7 +117,7 @@ $(function(){ value2html: function(value, element) { var text = '', data; - if(this.$input) { //when submitting form + if(this.$input) { //called when submitting form and select2 already exists data = this.$input.select2('data'); } else { //on init (autotext) //here select2 instance not created yet and data may be even not loaded. @@ -93,6 +126,8 @@ $(function(){ data = value; } else if(this.options.select2.data) { data = $.fn.editableutils.itemsByValue(value, this.options.select2.data, 'id'); + } else { + //if('ajax' in this.options.select2) { } }