Cleanup TinyMCE on Outcomes pages if it exists

Test Plan:

    - On the outcomes page, switch between two or more outcomes and
      observe that there are no JS errors (undefined type error)
    - edit an outcome, but click on a different outcome befor clicking
      either the cancel or submit buttons.  Observe no JS errors
    - edit an outcome.  Click cancel and then select a different
      outcome.  Observe no JS errors

Fixes CNVS-16825

Change-Id: I748b3e40b6e64eec78aa9c8ae2bd7eb708211486
Reviewed-on: https://gerrit.instructure.com/44283
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Simon Williams <simon@instructure.com>
QA-Review: Adam Stone <astone@instructure.com>
Product-Review: Benjamin Porter <bporter@instructure.com>
This commit is contained in:
Benjamin Porter 2014-11-13 18:06:33 -07:00
parent 05226c8092
commit aae40142f8
1 changed files with 5 additions and 1 deletions

View File

@ -121,6 +121,7 @@ define [
@$('form').toJSON() @$('form').toJSON()
remove: -> remove: ->
@_cleanUpTiny() if @tinymceExists()
@$el.hideErrors() @$el.hideErrors()
@model.destroy() if @state is 'add' and @model.isNew() @model.destroy() if @state is 'add' and @model.isNew()
super arguments... super arguments...
@ -178,7 +179,7 @@ define [
# Called from subclasses in render. # Called from subclasses in render.
readyForm: -> readyForm: ->
setTimeout => setTimeout =>
@$('textarea').editorBox() # tinymce @$('textarea').editorBox() # tinymce initializer
@setupTinyMCEViewSwitcher() @setupTinyMCEViewSwitcher()
@addTinyMCEKeyboardShortcuts() @addTinyMCEKeyboardShortcuts()
@$('input:first').focus() @$('input:first').focus()
@ -188,3 +189,6 @@ define [
updateTitle: (e) => updateTitle: (e) =>
@model.set 'title', e.currentTarget.value @model.set 'title', e.currentTarget.value
tinymceExists: =>
return @$el.find('[name="description"]').length > 0 and @$el.find('[name="description"]').editorBox('exists?')