I won't go into specifics of the code as I'm uncertain if it's breaking some license. Let's just say that if they moved a line of code four or five lines upwards, there wouldn't be any bug.
I wrote a simple patch for the bug. Put it in a CSJS library, and your code will work like it did on 8.5.2 (unless I made a stupid mistake).
/**
* Fix for bug with partialRefreshGet/-Post in 8.5.3
*/
(function(){
var oldPartialRefreshGet = XSP.partialRefreshGet;
XSP.partialRefreshGet = function( targetId, options ){
// Convert to array
var argsArray = Array.prototype.slice.apply( arguments );
if( argsArray.length > 1 ){ argsArray[1] = argsArray[1] || {}; }
if( argsArray.length === 1 ){ argsArray.push( {} ); }
oldPartialRefreshGet.apply( XSP, argsArray );
};
var oldPartialRefreshPost = XSP.partialRefreshPost;
XSP.partialRefreshPost = function( targetId, options ){
// Convert to array
var argsArray = Array.prototype.slice.apply( arguments );
if( argsArray.length > 1 ){ argsArray[1] = argsArray[1] || {}; }
if( argsArray.length === 1 ){ argsArray.push( {} ); }
oldPartialRefreshPost.apply( XSP, argsArray );
};
})();
This code should be forwards compatible with future API updates, as it doesn't assume number of arguments in function.
11 comments:
Do you mean the problem that a parameter is required in 8.5.3?
@Frederik: yep, the code seems to fix this. You can use XSP.partialRefreshGet("#{id:col1}"); in 8.5.3 then.
@Fredrik:
This seems to fix the "parameter"-problem.
@Fredrik: A second parameter is needed due to a bug in the code.
There is code that allows for no options parameter (the second parameter), but it's placed after a property is read from options. Hence if no options parameter is specified, the function tries to read a property from undefined -> code crashes.
The code I posted patches this bug.
Did you open an SPR? I can if you didn't.
I haven't. If you could, thanks.
Thank you! I have spent allmost 2 days trying to find out what was wrong. I nearly gave up, until I found your blogpost. It works !
Thanks! This was a big help.
Thanks much !
If you read the blogpost carefully, you can see that it's supposed to be put in a CSJS library. That is to say a Javascript library for the client/browser.
Really, really thanks. You saved my sanity
Post a Comment