Skip to content
This repository has been archived by the owner on May 25, 2019. It is now read-only.

uiRefresh, use $timeout to delay refresh until everything is loaded #68

Closed
nadersoliman opened this issue Sep 25, 2014 · 2 comments
Closed

Comments

@nadersoliman
Copy link

In lieu of issues #41 and #55 I had codemirror inside a tab. It is not refreshing despite adding ui-refresh attribute with proper model name something like

<textarea ui-codemirror="theOptions" ng-model="obj.samples_json" ui-refresh="obj.samples_json"></textarea>

Introducing the following patch fixed for me, and I guess it will fix it for others

$timeout(function(){codeMirror.refresh();}, 100);

@

codeMirror.refresh();

@nadersoliman
Copy link
Author

I made a directive to address this issue

.directive('cmlCodemirrorRefresh', [
  '$timeout'

  ($timeout) ->
    ###
      usage: <textarea ui-codemirror="options" ng-model="obj.samples_json" class="cml-codemirror-refresh"></textarea>
    ###
    restrict: 'C'
    link: (scope, element, attrs)->
      attrs.$observe 'ngModel', (value) ->
        #console.log 'to watch', value
        scope.$watch value, (newValue)->
          #console.log 'for ', value, 'got new value', newValue
          $timeout ->
            #console.log 'refreshing codemirror element', element.next()
            element.next()[0].CodeMirror.refresh()
          , 100
])

@naku
Copy link

naku commented Dec 5, 2014

Same issue with ui-codemirror + AngularStrap tabs combination.

This fix worked for me:

if (newVal !== oldVal) {
  $timeout(function() {
    codeMirror.refresh();
  });
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants