Commit 284921ea authored by Aron Carroll's avatar Aron Carroll Committed by Randall Leeds

Move the status button setup into the compile phase

parent 1b14908d
......@@ -23,21 +23,22 @@ statusButton = ->
</span>
'''
link: (scope, elem, attr) ->
targetForm = attr.statusButton
compile: ->
pre: (scope, elem, attr) ->
targetForm = attr.statusButton
unless targetForm
throw new Error('status-button attribute should provide a form name')
unless targetForm
throw new Error('status-button attribute should provide a form name')
wrapper = angular.element(template)
wrapper.insertBefore(elem)
wrapper.append(elem)
wrapper = angular.element(template)
wrapper.insertBefore(elem)
wrapper.append(elem)
scope.$on 'formState', (event, formName, formState) ->
return unless formName == targetForm
unless formState in [STATE_LOADING, STATE_SUCCESS]
formState = ''
wrapper.attr(STATE_ATTRIBUTE, formState)
scope.$on 'formState', (event, formName, formState) ->
return unless formName == targetForm
unless formState in [STATE_LOADING, STATE_SUCCESS]
formState = ''
wrapper.attr(STATE_ATTRIBUTE, formState)
angular.module('h.directives').directive('statusButton', statusButton)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment