2014년 12월 13일 토요일

[backbonejs] problem with backbone version 1.1.2

I have updated my backbone version to the most recent one.
Nonetheless I get an error in my code(in the console) which I did not get earlier(with the previous version I mean). 

Take a look at this jsbin. Go at the output pane in the calendar,click anywhere so as to make a dialog box appear and click OK....

While in the jsbin everything goes well,in my local machine, I get an error in the change function at the line:

 fcEvent.title = event.get('title');

The console says:Uncaught TypeError: Cannot set property 'title' of undefined 
I am attaching an image also.
Unfortunately I cannot replicate the behavior in jsbin.

Important note:
In the previous version the change function was not called when pressing the OK button in the dialog box-the OK button calls the save function



There is obviously some difference between you local code and jsbin version. Somewhere in this difference lurks the reason of that error. You should analyze this difference, this'll narrow down and pinpoint your bug.  



The problem with jsbin is that I cannot set breakpoints to see the flow...



 Use console.log and debugger



I understood that about the console.log....but how am I going yo use the debugger.
Where is the debugger in jsbin?



In jsbin the change function is not called...as I already said.

What I managed to do though is  that when creating an event(in jsbinand locally)....and I go to click the event,
jsbin console throws this error:

Uncaught TypeError: Cannot read property 'isNew' of undefined.

I get the same error locally.
I want to add also that in the new backbone version, a piece of code is called that in the older version simply does not exist.

I am talking about this function here.

The above function is called just before change is called....which is located in application.js....the code you will find in jsbin 



I have managed to solve partially the problem by binding the view to the model.
Take a look at this jsbin...
Go to the initialize function of EventsView...at the end of it you will see the binding code:
 this.test=new Event();
 this.listenTo(this.test, "change", this.render);

Nonetheless,the problem which remains,after creating an event,is that when I click an event the console emits this message
Uncaught TypeError: Cannot read property 'isNew' of undefined 

This appears on line 86 of the js code you see in jsbin.

I am still trying to find a solution....
The problem disappears when I refresh the page

It must not be something difficult....obviously,by updating backbone....I must make some changes in the code. 


댓글 없음:

댓글 쓰기