This topic is locked

Change details / child proceed to link

5/20/2016 12:48:19 PM
PHPRunner Tips and Tricks
F
FunkDaddy author

There are situations where you may want to display one inline child table on a master list page, but have it link to another child table (that is intentionally not included in the master list because it may offer more functionality). For example I have a master where I have linked two child tables. Both child tables use same data source table, but one has fewer fields on display in list page so it offers a simple summary, the other offers more columns and editing capabilities.
I want to show only the smaller summary child in the master but when user clicks on proceed to link, it takes them to the more robust child.
All you need to do is use jquery to hijack the proceed to details link like this:



//place this on the master's list page js event

//we simply hijack on mouseover event by targeting the proceed to details link's class... we bind to "on" event and pass in the selector because this allows us to bind to "future" dynamically added elements to the DOM.

//... this is important because child tables are generated on the fly and hence are not available when master page loads, they only get generated once you click on the details icon or link in the parent row.
$('table').on('mouseover', '.bs-proceed-link', function(){
//$(this).css('color','red'); //for visual debugging feedback or simply use console.log

var default_link = $(this).attr('data-plink');

var new_link = default_link.replace('summary_child_table_list.php','complex_child_table_list.php'); //replace the default link with new
$(this).attr('data-plink', new_link);
});


Cheers
Marcelo