EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: Coder on September 08, 2021, 10:23:39 AM



Title: [SOLVED] maskedbox: how change mask without recreate ?
Post by: Coder on September 08, 2021, 10:23:39 AM
Code:
  $('#Lat').maskedbox({
         label: 'Lat:'
        ,labelPosition: 'left'
        ,labelAlign: 'right'
        ,width: 300
        ,promptChar: '0'
        ,mask: '+99 99 99'
        ,masks: {'9':'[0-9]','+':'[\+\-]'}
        ,onChange: LatChange
        ,required:true
        ,validType:{GIS:['Lat']}
        ,buttonIcon: 'fas fa-map-marker-alt greentext'
        ,onClickButton: getLast
      });
  ...
  $('#Lat').maskedbox('button').tooltip({position: 'top',content: 'get last known position'});

 GIS format changer:
Code:
 let nVal = '+99 99.9999';
 $('#Lat').maskedbox({mask:nVal,masks: {'9':'[0-9]','+':'[\+\-]'}}).maskedbox('initValue','+')

then in console

Quote
VM5213:2890 Uncaught TypeError: Cannot read properties of undefined (reading 'tip')
    at Object.tip (<anonymous>:2890:31)
    at jQuery.fn.init.$.fn.tooltip (<anonymous>:2872:34)
    at HTMLInputElement.onShow (<anonymous>:7553:9)
    at <anonymous>:2822:13

trying

Code:
    if(($('#Lat').maskedbox('button')).hasClass('tooltip-f')
    ){
       $('#Lat').maskedbox('button').tooltip('destroy');
    };
   let nVal = '+99 99.9999';
   $('#Lat').maskedbox({mask:nVal,masks: {'9':'[0-9]','+':'[\+\-]'}}).maskedbox('initValue','+')
   $('#Lat').maskedbox('button').tooltip({position: 'top',content: 'get last known position'});

but get same error ...

do not get Uncaught TypeError only if don't create tooltip on button ;)


Title: Re: maskedbox: who to change mask without recreate ?
Post by: Coder on September 08, 2021, 01:42:17 PM
(http://2021-09-08 233908.jpg)


Title: Re: maskedbox: who to change mask without recreate ?
Post by: jarry on September 09, 2021, 12:30:18 AM
Please try to call this code instead.
Code:
var opts = $('#Lat').maskedbox('options');
opts.mask = '+99 99.9999';
opts.masks = {'9':'[0-9]','+':'[\+\-]'};
$('#Lat').maskedbox('initValue','+');


Title: Re: maskedbox: how change mask without recreate ?
Post by: Coder on September 12, 2021, 03:29:52 PM
its work, thnx!