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

Refresh problems when switching pages #111

Open

Description

@Ledragon

Hi everyone,
I started using the ui-codemirror directive a few days ago, and I have to say it is great. I however stumbled upon some refresh problems in a page with a parameter (not sure it is relevent though). What happens is that in some cases, my code is not rendered in the div where I use the directive. I have to click inside the element to have my code visible. After a bit of research, I came accross a StackOverflow post that helped me solve the problem.
I actually changed ngModel.$render (line 118 in ui-codemirror.js) to include a refresh using timeout after setValue:

var safeViewValue = ngModel.$viewValue || '';
      codemirror.setValue(safeViewValue);
        setTimeout(function() {
            codemirror.refresh();
        }, 100);

I don't think it is ideal/perfect, but it works...
I will try to post a plnkr of the not-working example later, to try and give a better overview of the problem. If I manage to reproduce it clearly, I will try and submit a PR comprising this fix (if it suits you of course).
Best regards,
Hugues

Activity

  1. darko371 commented on Dec 1, 2015

    @darko371

    Even with your patch I had the problem for codes on a hidden tab. Only on the visible tab on page load it helped correctly. A better solution seems to use the display/autorefresh.js addon from codemirror and setting autoRefresh:true in options. This solved the problem for all cases I had.

  2. Ledragon commented on Dec 22, 2015

    @Ledragon
    Author

    Thanks for the info, I will check that. My solution was more a workaround than a solution, I'm glad to hear there is a cleaner way.

  3. Ledragon commented on Jan 13, 2016

    @Ledragon
    Author

    @repetier Your solution worked for me as well, I therefore recommend using that solution instead of what I proposed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions