Mixin: SC.InlineEditor

This mixin is for a view that is editable but is acting as a proxy to edit another view. For example, a calendar picker that pops up over top of a date display.

Instantiation and destruction will be handled by the InlineEditorDelegate defined on the InlineEditable view.

Any runtime configuration should be handled by the delegate's inlineEditorWillBeginEditing method. This will be done at the start of the beginEditing function, so your view should be able to handle having value changed by this method.

Your view should also be sure to cleanup completely when editing is finished, because the delegate may decide to reuse the same editor elsewhere.

See SC.InlineTextFieldView for an example of an implementation of SC.InlineEditor.

Defined in: inline_editor.js

Field Summary

Class Methods

Field Detail

SC.InlineEditor.inlineEditorDelegate SC.InlineEditorDelegate

The delegate responsible for the editors lifecycle as well as the target for notifications. This property should be set when the delegate creates the editor and does not need to be in the view definition.

Default value:
null
SC.InlineEditor.isEditing Boolean

Indicates the view is currently editing. For a typical editor, this will always be true as long as the view exists, but some InlineEditorDelegates may have more complex lifecycles in which editors are reused.

Default value:
NO
SC.InlineEditor.isInlineEditor Boolean
Walk like a duck.
Default value:
YES

Class Method Detail

beginEditing(editable)

Tells the editor to begin editing another view with the given starting value. Editors may be reused so make sure that the editor is fully cleaned up and reinitialized.

Sets isEditing to YES.

Will fail if the editor is already editing.

If you override this method, be sure to call sc_super() at the beginning of you function so that the delegate will be able to configure the view when it is notified of the inlineEditorWillBeginEditing event.

Parameters:
editable SC.View
the view being edited
Returns:
Boolean
whether the editor was able to successfully begin editing
commitEditing()

Tells the editor to save its value back to its target view and end editing. Since the editor is a private property of the view it is editing for, this function should only be called from the editor itself. For example, you may want your editor to handle the enter key by calling commitEditing on itself.

Will fail if the editor is not editing or if the delegate returns NO to inlineEditorShouldCommitEditing.

Returns:
Boolean
whether the editor was allowed to successfully commit its value
discardEditing()

Tells the editor to discard its value and end editing. Like commitEditing, this should only be called by other methods of the editor. For example, the handle for the escape key might call discardEditing.

Will fail if the editor is not editing or if the delegate returns NO to inlineEditorShouldDiscardEditing.

Returns:
Boolean
whether the editor was allowed to discard its value
Documentation generated by JsDoc Toolkit 2.4.0 on Wed Apr 08 2015 10:02:20 GMT-0600 (CST)