skuid.utils.delayInputCallback

  • 1
  • Question
  • Updated 3 years ago
  • Answered
skuid.utils.delayInputCallback   is not working , i am passing 2 parameters but no alert showing...does not work
Photo of paras jain

paras jain

  • 264 Points 250 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Paras, this method is not documented in our skuid.utils API, what are you trying to use it to accomplish?
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,076 Points 10k badge 2x thumb
I haven't looked at this post closely but I ran in to an issue with delayInputCallback over the weekend.  If I'm reading the underlying skuid code correctly, this behavior changed slightly from 6.x to 7.x (uses .data('curval') now).

In both 6.x & 7.x the function passed to delayInputCallback will not be invoked if the value of the field hasn't changed.  However, in 7.x, the approach to detect the old/new value changed so only one event listener will actually be "called" whereas in 6.x, all listeners would be called.  I ended up moving to a different listening approach rather than use delayInputCallback.  In short, I registered an event listener (skuid.events.subscribe('row.updated')) in my jquery pluggin.  This turns out to be a more reliable approach anyway since in my case at least, I only want to do the post-change processing when a change actually occurs.  delayInputCallback had the shortcoming of possibly executing code when something else in the rendering process would "cancel" the edit (e.g. numeric only field, etc.).

Skuid Team - Can you confirm the change in behavior in 7.x or possibly I'm misreading the code?  If it did change, was it intentional?
Photo of Fakeha Quazi

Fakeha Quazi

  • 72 Points
I am using this textarea type field for this.
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,490 Points 10k badge 2x thumb
I'm looking at this now.
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,490 Points 10k badge 2x thumb
Yes, a change was made and an unintentional side effect was that only one delayInputCallback would work per input element. I'll see if we can fix this so they work as they did before.
Photo of Barry Schnell

Barry Schnell, Champion

  • 18,076 Points 10k badge 2x thumb
Thanks for looking at this and confirming Ben, appreciate you seeing what can be done to restore the previous behavior!
Photo of paras jain

paras jain

  • 264 Points 250 badge 2x thumb
I am showing the message no. of characters remaining on edit of field ...my code  is working fine earlier but now i have not change anything and it does not works...

code is...
var field = arguments[0],       value = skuid.utils.decodeHTML(arguments[1]),
    $ = skuid.$;
  
 // var vtdd = skuid.model.getModel('ArtFundAppwithInlineEdit').getField('installation_mission_fit__c');
//  alert('>>>>>>>>>>>>'+vtdd);
  
// Run the default renderer    
skuid.ui.fieldRenderers[field.metadata.displaytype][field.mode](field,value);
if (field.mode === 'edit') {
    
    var errorMessageBox;
    var addFieldError = function(errorMessage) {
        if (!errorMessageBox) {
           errorMessageBox = field.element.find('.field-error-messages');
           if(!errorMessageBox.length) {
               errorMessageBox = $('<div class="field-error-messages">');
               field.element.append(errorMessageBox);
           }
       }
       errorMessageBox.show();
       field.element.addClass('my-required-field');
       errorMessageBox.text(errorMessage);
     // alert('adsadacaca');
    };
    
    var input = field.element.find(':input');
    
    var MAX_VALUE = 10;
    var inputValueIsBad = function(inputValue) {
        var str = inputValue;
            var n = str.length;
      //  alert(n);
        return parseInt(n);
      //  alert('adsadacaca');
    }
    
    skuid.utils.delayInputCallback(input,function(newValue,oldValue){
        var val = input.val();
       if (inputValueIsBad(input.val())) {
           var inptText =input.val() ;
           var lengthText = inptText.length;
          // alert(lengthText);
           // Add an error
           if(lengthText<=255){
            var remainingCharacter = 255 - lengthText ;
            addFieldError('Remaining Characters are '+remainingCharacter);
           }
           if(lengthText>255)
           addFieldError('Hey! Dude You can not Enter more then '+'255'+' characters');
         //  addFieldError('Hey! Dude You can not Enter more then 255 characters');
           // And revert the value
        /*   if (inputValueIsBad(oldValue)) oldValue = 999999999;
           field.model.updateRow(field.row,field.id,oldValue);
           input.val(oldValue); */
       }  else {
           if (errorMessageBox) errorMessageBox.hide();
           field.element.removeClass('my-required-field');
       }
    });
}




>>>>>>>>>>>>>
Css used is 
.field-error-messages {       color: red;
    padding: 2px;
}
.my-required-field textarea, .my-required-field input  {
    border: 2px solid #D00;
    border-right: 2px solid #D00;
}
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,490 Points 10k badge 2x thumb
This should be fixed in Banzai Update 5. Available from the http://skuidify.com/skuidreleases page.