The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

gogogogo (3) [Avatar] Offline
#1
hello, i am totally new to Sencha and js programming. I was able after many attempts to have chapter 2 app running.

I just have one problem left, I noticed in Chrome debugger that (! model) always evalutes to FALSE, so even if no contacts are on the right list ! model returns true. This gives of course a bad behaviour when clicking on the Delete button and no contacts are there.

Could you please tell me why this happens, is this related to the differences between 1.0 and 1.1 versions?

The 2 places where this happen are:

onBtnTap : function(btn) {
var contactForm = this.items.items[0],
leftDock = this.getDockedItems() [1],
model = contactForm.getRecord(),
contactList = leftDock.items.items[0];

if (btn.action === 'deleteContact' && ! model) { <--HERE
return;
}

ContactListController.js

deleteContact : function(dataObj) {
var model = dataObj.model,
modelStore = model.store;

if (! model) { <--HERE
reutrn;
}
edde_se (1) [Avatar] Offline
#2
Re: in chapter 2 long example ! model always evaluates to true - help
Hi,

This will happen if you press the "New" button and then immediately press the "Delete" button before you save the new record. When you press the "New" button you create a new record and hence the model will exist. The "Delete" button is really only needed if the model also exists in the store so it's probably better to check for the existance of a store.

Change

if (! model) {
reutrn;
}

to

if (! modelStore) {
reutrn;
}

Cheers,
/Edde
gogogogo (3) [Avatar] Offline
#3
Re: in chapter 2 long example ! model always evaluates to true - help
Thanks for the reply, I did as you suggest, now ti works ok if there are no items on the left, but in case there are I cannot delete anymore. So it still doesn't work perfectly