Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

observableArray extended with deferred: true removes items from list #184

Open
ksirmons opened this issue May 4, 2017 · 2 comments
Open

Comments

@ksirmons
Copy link

ksirmons commented May 4, 2017

When observableArray is extended to be deferred like ko.observableArray([]).extend({ deferred: true }); some items disappear from GUI when dropped.

This is happening in knockout 3.4.2.

Found code in knockout-sortable where it checks for deferUpdates and runs ko.tasks.runEarly(); but this checks if all of knockout is being deferred, not a single observable array being extended to be deferred.

Changing the if statement
if (ko.options && ko.options.deferUpdates) { ko.tasks.runEarly(); }

to

if ((ko.options && ko.options.deferUpdates) || (sourceParent && sourceParent._deferUpdates)) { ko.tasks.runEarly(); }
fixes the issue for me.

Keith

ksirmons added a commit to ksirmons/knockout-sortable that referenced this issue May 4, 2017
@mbest
Copy link

mbest commented May 4, 2017

Checking _deferUpdates will only work if using the debug version of Knockout. I'm not sure if there's a way to check in all cases.

@ksirmons
Copy link
Author

ksirmons commented May 8, 2017

Would it hurt to just run ko.tasks.runEarly(); every time, and not check for 'if deferUpdates'?
if (typeof ko.tasks.runEarly === "function") { ko.tasks.runEarly(); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants