What is best way to fire event on controller connect()?

I was going to update something someplace about this topic and how it relates to a couple of posts I wrote a few months ago (One controller or multiple controller and A spreadsheet like controller…), one which was referenced. Guess here is as good as place than any.

I was trying to do something similar in the spreadsheet post, firing another controller. For instance you have two numeric inputs (e.g., frontTarget and backTarget that you want to sum and update a totalTarget, then have another controller add the totalTargets and set a total cell.

I had some kludge that fired the other controller. The solution provided by welearnednothing was simple: the front and back targets are referenced in both controllers and the change action does the addition in the first controller and the sum or compute actions is handed by the second controller. Since tables are like spreadsheets, the data rows(TR) contain the inner controller and the table contains the outer controller.

td= text_field_tag("participant[#{mate.id}][front]", mate.front,
  data:{target:'scoreMate.mateFront scoreTeam.mateFront',
  action:"change->scoreMate#front change->scoreTeam#compute"},class:"w100")
td= text_field_tag("participant[#{mate.id}][back]",mate.back, 
  data:{target:'scoreMate.mateBack scoreTeam.mateBack',
  action:"change->scoreMate#back change->scoreTeam#compute"},class:"w100")

I’ve also implemented it with a single controller using all kinds of indexes, but the two controller is much more readable and maintainable.

Just my2cents.