Sunday 15 July 2012

knockout.js - Breezejs does not trigger knockout update if relation is deleted -


I am playing with airage, and I have a problem which is not a calculated read readable update. Explain me with a prepared example:

I have a unit (session) which is one-to-many relationship with another organization (speaker). I get all the related speakers using all extended functions in freezes:

  wind AntityQuery.from ('Session'). Expand ('Speaker');   

On the air manager, I am configuring a countable view in the entity constructor:

  var mgr = new breeze.EntityManager (config.remoteServiceName) ; Mgr.metadataStore.registerEntityTypeCtor ('session', blank, session initiator); Function session initiator (session) {session.hasOldSpeaker = ko.computed (function (for (var i = 0; i & lt; session speaker.lamp; i ++) {var speaker = session. Speaker [i ]; If (speaker .age ()> 40) {return true;}} return false;});}   

Then I can hear this view in view:

  & lt; span data-bind = "visible: session.hasOldSpeaker" & gt; ... and & lt; / span & gt;   

now my Has a button that can remove the old speaker from a session, so that we no longer have the old speaker. I request general ajax because it is not updating the database, some other work should also be done, so I do not think I can do it through the air anyway, after the work is complete I refresh the unit To summarize the air: var refreshQuery = Winds. Antititactivity. Entity (session). Expand ('speaker'); manager.executeQuery (refreshQuery);

works fine to refresh, because the session The list of related speaker is now empty - but this view is not updated to hide the above period.

Do anyone know why calculation binding is not renewed?

If I refresh the page, then it hides the right time.

Update

After checking for all the speakers for the deleted session using the unit of Breeze, after testing, I can see that Knockout binding works as expected, so I think the problem is in that session, the way I refresh the session unit. Maybe someone has a better way of using air like this? - This is not just a database update, I have to shut down some work on the server too. What is the best way to do this with Breeze?

can tell me what it is not, that according to your calculation, the knockout is the property of the heelshocker For, know only about subscribing to the age of the speaker (if you change the speaker of the session, do not change)

Because you are calculating the hasOldSpeaker property and only the property of the age To subscribe, except for the speaker age by changing the session or speaker only Will not subscribe to anything I can tell. If your content is calculated, then the session speaker should subscribe correctly for the property.

  function session initiator (session) {session.hasOldSpeaker = ko.computed (function () {if (session.speaker)} {For (var i = 0; i & lt; session. Speakers.length; i ++) {var speaker = session.speakers [i]; if (speaker.age ()> 40) {true}; else} return false;}}} return false;}); }    

No comments:

Post a Comment