Skip to content

Instantly share code, notes, and snippets.

@takuyan
Created October 10, 2014 03:06
Show Gist options
  • Select an option

  • Save takuyan/d0697729daff3138ed29 to your computer and use it in GitHub Desktop.

Select an option

Save takuyan/d0697729daff3138ed29 to your computer and use it in GitHub Desktop.

Revisions

  1. takuyan revised this gist Oct 10, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion insertAtCurrentCaret.js.coffee
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    // require https://github.com/ichord/Caret.js
    # require https://github.com/ichord/Caret.js

    $target = $('#post_body')
    insertText = "Hello World"
  2. takuyan created this gist Oct 10, 2014.
    8 changes: 8 additions & 0 deletions insertAtCurrentCaret.js.coffee
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    // require https://github.com/ichord/Caret.js

    $target = $('#post_body')
    insertText = "Hello World"
    text = $target.val()
    position = $target.caret('pos')
    newText = text.substring(0, position) + insertText + text.substring(position)
    $target.val(newText)