Scenario:
I have a Master / Child form where I was adding inline records and also editing them. I needed a way to detect what type of action was being called when inline add or edit buttons were clicked.
While recent releases of PHPR added the inlieRow object to JS OnLoad events, it can only handle cancel triggers.
Also, the "Before Record Added" events in add or edit pages are only usable precisely on that timing right before records is saved, and hence not useful for manipulating the DOM elements (fields, labels, etc) on their respective pages.
Long story short... I added the following code to "Add Page --> JS OnLoad" event
//I modified url parameter parsing function from link below
//http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values
function getParameterByName(name,url){
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(url);
if(results == null)
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
//This will now detect when the AJAX call is made for either add or edit pages (inspect your browser console and you'll see the XHR requests taking place)
$(document).ajaxComplete(function(event,xhr,settings) {
var url_param = "editid1"; //This is the name of the query string parameter that is used exclusively by the inline edit ajax call (it's omitted from inline add calls)
var url_param_value = getParameterByName(url_param,settings.url);//Lets use our getParameterByName function to parse the XHR request
if (url_param_value > 1) {
//This tells us it is an inline edit request
console.log("INLINE EDIT");
//Do something
}else{
//This tells us inline add
console.log("INLINE ADD"); //do something, etc
}
});
Done. Now you can tell which type of page is being called when using inline add or edit!