0

I have a problem that seems pretty specific to my plugin but I don't know enough about backbone.js to solve.

Pretext: My plugin injects some DOM elements to control its features and script elements to interface with the page and send events to my plugin's backend.

The Problem: Backbone does some sort of cleaning of the page and removes all of my elements but leaves the original page alone. I know this is backbone because I traced the remove event to part of backbones script. I also know its not plug.dj because they have no reference in their code to anything that could detect my elements. I need to know how to prevent backbone.js from removing my elements or find a way to detect when backbone is done culling the page so I can inject at that time.

If anyone knows of a flag I can put on the elements to prevent this from happening or some sort of flag that tells me backbone is finished, it would be greatly appreciated.


My plugins code is available here: https://github.com/tyduptyler13/PlugPlus/tree/dev (Keep in mind its the dev branch! Master branch is the last stable version, the dev has some new beta features I was testing.)

This code is the most up to date version available to the public and all versions have this issue after plug.dj made the change to backbone.js.

For plug.dj code you will need to dig manually on their site http://plug.dj/

And finally, to test their site with my code you will need to add it from the chrome store.

Tyler Scott
  • 1,046
  • 17
  • 33
  • Can you show your code which exhibits this behaviour? – Rob W Jul 20 '13 at 19:45
  • I updated the question to have all of the source available. – Tyler Scott Jul 20 '13 at 19:53
  • That's quite a lot of code. With your knowledge of the code, you should be able to create a small example that replicates the problem. PS. Your way of using Google Analytics is incorrect by the way. To fix is, read http://stackoverflow.com/a/10371025/938089. – Rob W Jul 20 '13 at 19:58
  • Well I know for sure my GA works because I mixed two solutions for the issue and its been working ever since. My solution allows for their site to have their own namespace for GA and mine to run separately. As for my code. It has worked the whole time, its a recent update for their site that has broken my code and it appears to be a backbone culling. For some reason my DOM elements are removed in the backbone.html method. – Tyler Scott Jul 20 '13 at 20:03

1 Answers1

0

I ended up ignoring the fact that backbone was culling my content by doing an interval based check to see if backbone was finished "rendering" the page. If you add content after backbone has finished it won't overwrite it or remove it.

Tyler Scott
  • 1,046
  • 17
  • 33