Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
moving elements and handling events
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Michael Kato Wulf  
View profile  
 More options Sep 19 2012, 5:03 pm
From: "Michael \"Kato\" Wulf" <katow...@gmail.com>
Date: Wed, 19 Sep 2012 14:03:51 -0700
Local: Wed, Sep 19 2012 5:03 pm
Subject: moving elements and handling events

Hello gents,

I'm looking to control some sorted lists using an event-based model
(pre-existing). Adding and deleting elements works wonderfully.

However, when an element is moved in the array, this (naturally) triggers a
delete followed by an add event. My best guess is to use setTimeout (ick)
and simply wait around some small length (20 ms) to see if an add event
immediately follows.

This seems a bit sloppy and unreliable (what if there is a lot going on and
the timeout is exceeded? what if a large number of moves take place, each
delayed by x ms?)

Is there a simple way I could suppress the delete/add notifications and
create my own from within knockout? Maybe using an extender?

I'm not looking for anyone to write the code--I'll do my homework and ask
questions if I have issues.

I simply want to see if any features or patterns spring to mind that I
should investigate or if this is a previously invented wheel.

Cheers,

--
Michael Wulf
775-235-8398
web site <http://www.michaelwulf.com> |
contact<http://www.michaelwulf.com/blog/chat-with-wulf>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Best  
View profile  
 More options Sep 19 2012, 6:32 pm
From: Michael Best <mb...@dasya.com>
Date: Wed, 19 Sep 2012 15:32:27 -0700 (PDT)
Local: Wed, Sep 19 2012 6:32 pm
Subject: Re: moving elements and handling events

The next version of Knockout, 2.2, will include beforeMove and afterMove
events for moved items. This is already included in the code available in
GitHub (https://github.com/SteveSanderson/knockout), which you can use to
build the latest Knockout. In your case, if you want to respond to only a
single event, you could just pick either one. One caveat, though, is that
deleting or adding an item will cause other items to move, triggering move
events for them.

-- Michael


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Kato Wulf  
View profile  
 More options Sep 19 2012, 6:40 pm
From: "Michael \"Kato\" Wulf" <katow...@gmail.com>
Date: Wed, 19 Sep 2012 15:40:08 -0700
Local: Wed, Sep 19 2012 6:40 pm
Subject: Re: moving elements and handling events

Is there also a move method then? Or does 2.2 utilize a similar pattern to
what I was looking for, reading a delete/add of the same record as a
move? (right now I'm using splice() to move the records--I assume ko is
taking a similar approach)

--
Michael Wulf
775-235-8398
web site <http://www.michaelwulf.com> |
contact<http://www.michaelwulf.com/blog/chat-with-wulf>

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Best  
View profile  
 More options Sep 19 2012, 9:42 pm
From: Michael Best <mb...@dasya.com>
Date: Wed, 19 Sep 2012 18:42:31 -0700 (PDT)
Local: Wed, Sep 19 2012 9:42 pm
Subject: Re: moving elements and handling events

There is not a separate move method for observableArray.

In 2.2, the foreach binding will treat an item that has a different index
in the array (from the last time the binding was updated) as a moved item.

-- Michael


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »