Skip to main content

skuid.utils.delayInputCallback   is not working , i am passing 2 parameters but no alert showing…does not work

Paras, this method is not documented in our skuid.utils API, what are you trying to use it to accomplish?


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 = argumentsu0], value = skuid.utils.decodeHTML(argumentsu1]),

$ = 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;

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;

}


Can u help me, to find out where is the problem?


any solution?


This method is now documented in the skuid.utils API. 


But this method is not working.


I used this simple example from the Skuid tutorials,


<ol><li>var field = arguments[0], &nbsp; &nbsp;<br></li><li>&nbsp; &nbsp;value = skuid.utils.decodeHTML(arguments[1]); <br></li><li>// Run the default renderer &nbsp; &nbsp;<br></li><li>skuid.ui.fieldRenderers[field.metadata.displaytype][field.mode](field,value);<br></li><li>if (field.mode==='edit') { &nbsp; &nbsp;<br></li><li>&nbsp; &nbsp; var input = field.element.find(':input');<br></li><li>&nbsp; &nbsp; &nbsp;skuid.utils.delayInputCallback(input,function(newValue,oldValue){<br></li><li>&nbsp; &nbsp; &nbsp; &nbsp;console.log('[' + field.id + '] New value: ' + newValue +', old value: ' + oldValue);<br></li><li>&nbsp; &nbsp; });<br></li><li>}<b></b></li></ol>

But it is not working.


How are you calling this snippet?  Can you show a screenshot of your JS item properties panel? 


What type of field are you using this custom renderer on? For example, Picklist, Textarea, etc?


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?


I am using this textarea type field for this.


I’m looking at this now.


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.


Thanks for looking at this and confirming Ben, appreciate you seeing what can be done to restore the previous behavior!


This should be fixed in Banzai Update 5. Available from the http://skuidify.com/skuidreleases page.