Need help migrating from CanJS 2.2 to 2.3 - attrs and in bind change not syncing in views

We at atVenu (Hi @daffl - remember Calgary? :grinning:) are trying to migrate from CanJS 2.2 to CanJS 2.3 because we upgraded jQuery from 1.11 to 1.12.

We are trying to do the minimum, and landed on 2.3.11 because it seems to have the least differences - until now.

We are having a heck of a time getting our Mustache views to update when we change attrs in the bind change event. This worked fine in CanJS 2.2, but is broken in CanJS 2.3.11 and 2.3.28.

Here is a working example in CanJS 2.2,js,output
If the value of box is ‘no’ then you cannot check the flag. The change handler resets it back to false.

Here is a broken example in CanJS 2.3.28,js,output
If the value of box is ‘no’ then you can check the flag once and then the view gets stuck in the True state (when it should be False). The attr in the model may actually be false - but it is out of sync.

Any help on this would be appreciated.

Could you do it in a set timeout like I’ve done here:,js,output

2.3 and prior had a batching system that would break under certain circumstances. This is almost certainly one of those circumstances. Setting a timeout always makes sure new changes will run within a new batch.

Thanks for the reply,

I think the jsbin you mention needs to be saved or cloned and given a new URL, because the one you pasted seems to be my original broken one.


bob.bind('change', function(event, identifier, type) {
    if (type == 'set' && !event.batchNum) {
      flag = bob.attr('flag');
      box = bob.attr('box');
      if (flag && box === 'no') {
        bob.attr('flag', false)
      // Save Changes to Server...

Thanks Justin,

I will give it a try.


Thanks Justin,

Your advice is fixing the issue.