how to dynamically (with javascript) add a model to a save/cancel button

Raymond is on the right track here.

Unfortunately, there isn’t a stock way to add models to buttons or be able to establish actions declaratively on.  But, using Raymond’s thought process, you can achieve the desired result.

1) Add a new model to your page (e.g. ChangeTracker).  Base it on any existing SObject in the system.  Mark it to “not load data” and “Create new row if none.”  Add a UI Only Field called “ModelsHaveChanges” as a Boolean with default value of “false”
2) Conditionally render the button in question based on Model & Field from #1 where it equals true
3) In an inline snippet, subscribe to the various model events (e.g. row.updated, row.created, models.saved, etc.).  In the snippet, check the modelId of the argument passed to compare against the models that you are “tracking” for changes.  When you get a change in one of those models, update the field on the model in #1 to “true”.  Also, check for when models were saved/cancelled so you can set the value to false as appropriate.

Hope this helps!