Skip to content

Instantly share code, notes, and snippets.

@gcr
Created January 16, 2009 23:13
Show Gist options
  • Save gcr/48203 to your computer and use it in GitHub Desktop.
Save gcr/48203 to your computer and use it in GitHub Desktop.
this.parse_new_chunk = function(event) {
// This gets called whenever an event for a new chunk comes in.
var newchunk = .text(event.text);
// Get the position we want to insert at
var pos = event.position - 1;
console.log(pos);
// HACK: Are we at the beginning?
if (pos == -1) {
// If so, add it at the very beginning.
newchunk.prependTo(this.jqedit);
} else {
// If not, insert it after the specified chunk.
newchunk.insertAfter(this.jqedit.find(.chunk).eq(pos));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment