angular-turbolinks icon indicating copy to clipboard operation
angular-turbolinks copied to clipboard

Expose .visit() method in a publishable interface

Open clyfe opened this issue 11 years ago • 0 comments

DHH's Turbolinks allows for programatic Turbolinks.visit(url). Angular-turbolinks should also expose it's .visit() method in something like maybe a service I believe (ng noob).

For example I have a modal I load with forms. Forms submit via rails-ujs data-remote=true. On ajax:success I'd like to refresh via Turbolinks (angular-turbolinks), having the new page ng-compiled.

app.directive 'cyModalAjaxForm', ($compile, $rootScope, $location) ->
  link: (scope, element, attrs) ->
    element.on 'ajax:success', (event, data) ->
      $modal = element.closest('.modal')
      $modal.modal('hide')
      Turbolinks.visit($location.url()) #    <- my page won't be $compiled :(
      # $ngTurbolinks.visit($location.url()) <- this is what I need
    element.on 'ajax:error', (event, data) ->
      compiled = $compile(data)($rootScope);
      $modal = element.closest('.modal')
      $modal.html(compiled)

clyfe avatar Apr 30 '14 08:04 clyfe