bootstrap-ruby / bootstrap-editable-rails

In-place editing with Twitter Bootstrap for Rails
http://rubygems.org/gems/bootstrap-editable-rails
MIT License
216 stars 52 forks source link

Uncaught RangeError: Maximum call stack size exceeded #20

Closed roblingle closed 10 years ago

roblingle commented 10 years ago

Not sure this is really an issue for you, but I've seen a couple people run into it with bootstrap-editable-rails and x-editable-rails. It seems to happen with turbolinks. I think we fixed it for ourselves.

We're using editable in a maybe slightly unusual way, so I'm not sure most Rails apps would ever see this. We have all of our photos on a page and a user can click a photo to bring up the details in a modal for view and edit. This means we have to change Editable options on each photo click event, but I don't think that was causing the problem.

We started seeing this:

Uncaught RangeError: Maximum call stack size exceeded bootstrap-editable-rails.js?body=1:9
(anonymous function) bootstrap-editable-rails.js?body=1:9
EditableForm.saveWithUrlHook bootstrap-editable-rails.js?body=1:33
EditableForm.saveWithUrlHook bootstrap-editable-rails.js?body=1:34
... more of these ...

I found the problem happens when the user clicks a photo to bring up the modal (makes changes which do work normally or changes nothing), goes to another page, comes back, makes a change to an editable field, and clicks save.

Seems to be somewhere around here:

originalUrl = this.options.url
...
this.options.url = function(_this){ 
    ...

After a page change, this.options.url became a recursive call to itself. To get around it, I removed //= require bootstrap-editable-rails from application.js and replaced it with a slightly modified coffeescript version in this gist. Seems happy now.

Hope it helps, and thanks!

tkawa commented 10 years ago

Thank you for reporting :satisfied: I was not expecting turbolinks (& probably jquery-turbolinks), so the problem you say is likely to occur. I think It is only necessary to ensure this script doesn't run twice. Anyway, I'll continue to look into it. :mag:

tkawa commented 10 years ago

@roblingle I tried to fix this issue in very simple way. It works on my code. Please try this fix on your code. If it works, I release it soon.

roblingle commented 10 years ago

Looks like a fix. Thanks!

On Mon, Jun 9, 2014 at 5:55 AM, Toru KAWAMURA notifications@github.com wrote:

@roblingle https://github.com/roblingle I tried to fix this issue in very simple way. It works on my code. Please try this fix on your code. If it works, I release it soon.

— Reply to this email directly or view it on GitHub https://github.com/bootstrap-ruby/bootstrap-editable-rails/issues/20#issuecomment-45476091 .

tkawa commented 10 years ago

I've released it. Thanks a lot! :satisfied: