Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 436
Simon Avatar asked Jun 25 '13 09:06

Simon


3 Answers

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/

like image 140
romelmederos Avatar answered Nov 13 '22 12:11

romelmederos


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

like image 43
stevenspiel Avatar answered Nov 13 '22 11:11

stevenspiel


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

Worked really well.

like image 1
venkatareddy Avatar answered Nov 13 '22 12:11

venkatareddy