@@ -654,26 +654,23 @@ define([
654
654
655
655
/**
656
656
* Bind columns source function
657
- * @param {string } selector thisWrapSelector
658
- * @param {object } target
657
+ * @param {object } pageThis
658
+ * @param {object } targetId
659
659
* @param {array } columnInputIdList
660
660
* @param {string } tagType input / select (tag type)
661
661
* @param {array/boolean } columnWithEmpty boolean array or value to decide whether select tag has empty space
662
662
* @param {array/boolean } columnWithIndex boolean array or value to decide whether select tag has index option
663
663
* Usage :
664
664
* $(document).on('change', this.wrapSelector('#dataframe_tag_id'), function() {
665
- * pdGen.vp_bindColumnSource(that.wrapSelector(), this , ['column_input_id'], 'select', [true, true, true]);
665
+ * pdGen.vp_bindColumnSource(that, 'dataframe_tag_id' , ['column_input_id'], 'select', [true, true, true]);
666
666
* });
667
667
*/
668
- var vp_bindColumnSource = function ( selector , target , columnInputIdList , tagType = "input" , columnWithEmpty = false , columnWithIndex = false ) {
669
- var varName = '' ;
670
- if ( $ ( target ) . length > 0 ) {
671
- varName = $ ( target ) . val ( ) ;
672
- }
668
+ var vp_bindColumnSource = function ( pageThis , targetId , columnInputIdList , tagType = "input" , columnWithEmpty = false , columnWithIndex = false ) {
669
+ var varName = pageThis . state [ targetId ] ;
673
670
if ( varName === '' ) {
674
671
// reset with no source
675
672
columnInputIdList && columnInputIdList . forEach ( columnInputId => {
676
- let defaultValue = $ ( selector + ' #' + columnInputId ) . val ( ) ;
673
+ let defaultValue = pageThis . state [ columnInputId ] ;
677
674
if ( defaultValue == null || defaultValue == undefined ) {
678
675
defaultValue = '' ;
679
676
}
@@ -735,7 +732,7 @@ define([
735
732
736
733
// columns using suggestInput
737
734
columnInputIdList && columnInputIdList . forEach ( ( columnInputId , idx ) => {
738
- let defaultValue = $ ( selector + ' #' + columnInputId ) . val ( ) ;
735
+ let defaultValue = pageThis . state [ columnInputId ] ;
739
736
if ( defaultValue == null || defaultValue == undefined ) {
740
737
defaultValue = '' ;
741
738
}
@@ -771,7 +768,7 @@ define([
771
768
option . append ( document . createTextNode ( listVar . label ) ) ;
772
769
$ ( tag ) . append ( option ) ;
773
770
} ) ;
774
- $ ( selector + ' #' + columnInputId ) . replaceWith ( function ( ) {
771
+ $ ( pageThis . wrapSelector ( ' #' + columnInputId ) ) . replaceWith ( function ( ) {
775
772
return $ ( tag ) ;
776
773
} ) ;
777
774
}
0 commit comments