Giter Club home page Giter Club logo

Comments (5)

SamSaffron avatar SamSaffron commented on July 30, 2024

And so it begins 😄 I am not sure I want to get into the business of jumping through hoops to support turbolinks, however if you can think of a change that adds no additional lines of code and simply reorders stuff a bit I am open to it.

from miniprofiler.

denniskuczynski avatar denniskuczynski commented on July 30, 2024

Alright, I dug a little deeper into the code.

The only reason there's an issue is the body tags dynamically inserted: the results container div and the jquery template scripts, get clobbered by turbolinks update of the body.

Here's a script which makes everything work with turbolinks. It stores those tags in the window namespace, and drops them back into the body in after turbolinks has updated the page.

This can probably just exist as a separate script patch for now. The jquery templates might be able to be stored in the head always, but a special hook would be needed to deal with the container div.

# Store detached versions of body tags inserted by MiniProfiler when fetching a new page with Turbolinks
storeMiniProfileBodyTags =->
  if $('#mini-profiler').length and not window.MiniProfileBodyTags
    window.MiniProfileBodyTags = {}
    window.MiniProfileBodyTags.Container = $('.profiler-results').detach()
    window.MiniProfileBodyTags.Templates = $('script[type="text/x-jquery-tmpl"]').detach()

# Copy detached tags back into the body when changing pages with Turbolinks
migrateMiniProfileBodyTags =->
  if window.MiniProfileBodyTags
    $body = $('body')
    $body.append(window.MiniProfileBodyTags.Container)
    $body.append(window.MiniProfileBodyTags.Templates)

# doc.ready init
$ ->
  $(document).bind('page:change', migrateMiniProfileBodyTags)
  $(document).bind('page:fetch', storeMiniProfileBodyTags)

https://gist.github.com/4289111

from miniprofiler.

SamSaffron avatar SamSaffron commented on July 30, 2024

I am open to a patch in include.js that works around this issue, either that or a note in the readme

care to submit a PR

from miniprofiler.

denniskuczynski avatar denniskuczynski commented on July 30, 2024

I just spun up a quick Rails 3 test app, and didn't notice the error I saw previously. I no longer have the source code for the original app, but perhaps this is no longer an issue?

If you're still having reports of similar issues I can try digging around a bit more.

from miniprofiler.

keyeh avatar keyeh commented on July 30, 2024

I'm getting a similar error when I use AJAX to submit forms. (using a form_tag with remote:true). I'm also using turbolinks 3

Uncaught TypeError: result.appendTo is not a function

from miniprofiler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.