Simon
Simon

Reputation: 1736

Textarea resizes and triggers best_in_place blur event

I'm using the best_in_place gem on several textareas and sometimes (seemingly randomly) the textarea 'jumps' and triggers the blur event when I click save, prompting the "discard your changes" warning.

Here's the code:

<p>
  Administrator Notes (<%= link_to 'Edit', '#', id: 'edit_notes_link', onclick:
  'event.preventDefault()' %>)
</p>
<div class="panel radius">
  <%= best_in_place [:admin, @booking], :notes, type: :textarea, ok_button:
  'Save', cancel_button: 'Cancel', activator: '#edit_notes_link', display_with:
  :simple_format, nil: '<i>None</i>' %>
</div>

And here's a GIF of the behaviour:

(And the video that GIF was taken from)

I'm guessing that there's some JavaScript skulduggery going on somewhere but I don't know where to begin debugging it. If you've seen Best in Place behave like this or you have some pointers for how to debug it then I'd really appreciate some help.

Upvotes: 39

Views: 1083

Answers (4)

Priyanjana
Priyanjana

Reputation: 11

Would recommend breaking down the DOM breakpoint actions and checking the logs first if you are using the basic chrome dev tools , if you have to absolutely use best-in-place. Will help you isolate the issue.

But if not, X-editable is a bit more easier to use.

Upvotes: 1

venkatareddy
venkatareddy

Reputation: 775

I haven't used best-in-place gem but I had a similar requirement. I've used x-editable

Worked really well.

Upvotes: 1

stevenspiel
stevenspiel

Reputation: 5999

I was running into the same issue, and just removed the ok_button. It seems to be working fine now.

Upvotes: 1

romelmederos
romelmederos

Reputation: 198

If you are using firebug try turning on log events to get more information. Here is an article explaining it http://www.softwareishard.com/blog/firebug/firebug-tip-log-dom-events/

Upvotes: 1

Related Questions