form with attribute data-remote=true being submitted without ajax on second attempt

form with attribute data-remote=true being submitted without ajax on second attempt

I have a form form with attribute data-remote=true and is submitted without ajax on second attempt. I am using ruby on rails on server side.

First attempt is going in javascript format and javascript is being returned. here is the java script being returned

$('form[id*="restaurant"]').html('<%= escape_javascript render("form") %>')

Form is not getting submitted as ajax in second attempt. It appears the form is losing it's binding to be submitted through ajax.

Any ideas to fix the issue?