Closed dennisharrison closed 12 years ago
So, this may be true, but it sounds a bit fishy to me.. Here's the only thing I can think of -- to keep from polluting your document, as well as several other things, Mercury will reload the document to be edited into an iframe. Is there something that you're doing with tokens or something? Even still, I believe I have tests around the query params being passed to the iframe.
Anyway, let me know if I can help more, but that's the only thing I can think of off hand, and it seems quite unlikely. You might also want to use to_json instead of gsub -- there's a lot of characters that will break javascript (line feeds, quotes, and apostrophes to name a few) and html_safe does not escape those.
Did you ever sort and/or figure this out?
Howdy,
Sorry to say I haven't been able to look at it in depth yet. I wanted to do a sanity check, so I created a new project with just mercury and devise (using the bare bones devise setup from Jose Valim at http://blog.plataformatec.com.br/2011/09/bare-bone-stripped-down-devise/ ), I added a route to load the mercury editor like so :
resources :test_model do get 'mercury_edit' post 'mercury_update' end
with those methods in the controller rendering the template that loads mercury like so:
<%= javascript_include_tag 'mercury_loader.js' %>
I know you said that gsub would perhaps be a culprit here, and I'll look at that next, but I just wanted to make sure I was looking in the right place at all. This is only using the example snippet you have for First Name like Beer (which... by the way, I do ever so like the beer). I am not getting any javascript errors, and I'm not even sure I'm using loadPreview correctly, or if that's supposed to be the case.
Everytime I run: top.Mercury.Snippet.all[<%= s.gsub('snippet_', '') %>].loadPreview($('[data-snippet="<%= s %>"]'));
The devise session is destroyed. My next steps are to sprinkle some puts and setup an observer for the devise model to see what it thinks is going on, and bringing mercury up in textmate to be able to easily search around in it and hope for some ah-ha moment :)
Won't really have time for that until Friday. I was hoping that the barebones project setup like this would just 'work' and that I would be left with the relatively easy task of finding out where I messed up.
What are you using for auth in your projects currently?
Dennis
any confirmation on this?
Added auth to the test Mercury app today. Have been using Devise for this. Perhaps my implementation is incorrect?
$(document).ready(function(){ <% if @model.content_snippets %>
<% end %> });
The offending line is: top.Mercury.Snippet.all[<%= s.gsub('snippet_', '') %>].loadPreview($('[data-snippet="<%= s %>"]'));
Shutting everything down for the day and just ran across the issue. Haven't looked into the Mercury code yet, will do that first thing in the morning. Starting the issue now, in-case you happen to use Devise, or you can see an obvious error in the way I'm trying to use snippets.
Thanks again
Dennis