Created
January 28, 2014 04:09
-
-
Save songjiayang/8662113 to your computer and use it in GitHub Desktop.
this textarea cell supports text area with line breaks ..
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery ($)-> | |
_.extend Backgrid.Command.prototype, { | |
save: () -> | |
!@shiftKey && @keyCode is 13 | |
moveUp: () -> | |
@shiftKey && @keyCode is 38 | |
moveDown: ()-> | |
@shiftKey && @keyCode is 40 | |
} | |
class Backgrid.TextareaFormatter extends Backgrid.StringFormatter | |
fromRaw: (rawValue, model)-> | |
rawValue = rawValue.replace /</g, "<" | |
rawValue = rawValue.replace />/g, ">" | |
rawValue.replace /\n/g, '<br />' | |
class Backgrid.TextareaEditor extends Backgrid.InputCellEditor | |
tagName: 'textarea' | |
render: ()-> | |
@$el.val @model.get(@column.get("name"), @model) | |
class Backgrid.TextCell extends Backgrid.StringCell | |
className: "text-cell" | |
editor: Backgrid.TextareaEditor | |
formatter: Backgrid.TextareaFormatter | |
render: ()-> | |
@$el.empty() | |
@$el.html(@formatter.fromRaw(@model.get(@column.get("name")), @model)) | |
@delegateEvents() | |
@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment