problems with ajax form

20 views
Skip to first unread message

Andrew Dig

unread,
Feb 25, 2016, 2:00:15 PM2/25/16
to rubyonra...@googlegroups.com
Hi everyone! A few days I can't resolve a task. I want to build a single
page app without any page refresh. So I have a button 'Add', onclick it
inserts in a DOM a simple remote:true form and when I try to submit this
form - nothing happens BUT if i refresh the page - it works. Guess some
handler is absent but not sure. Advise please. Here's my form
<%= form_tag(:add_task, method: 'post', remote: true) do %>
<td>
<span class="glyphicon glyphicon-plus"></span>
</td>
<td>
<%= text_field(:task,:project_id,type: 'hidden',value:
@project.id)%>
<%= text_field(:task,:name,class: 'form-control
task_field', placeholder: 'Start typing here to create a task...')%>
</td>
<td>
<%= button_tag('Add task',class:'btn btn-add_task') %>
</td>
<% end %>

--
Posted via http://www.ruby-forum.com/.

Colin Law

unread,
Feb 25, 2016, 3:06:11 PM2/25/16
to Ruby on Rails: Talk
The first thing to do is to look in development.log and see if it
submitting correctly.

Colin

Andrew Dig

unread,
Feb 25, 2016, 4:04:34 PM2/25/16
to rubyonra...@googlegroups.com
already checked. nothing written in the log

Colin Law

unread,
Feb 25, 2016, 4:29:17 PM2/25/16
to Ruby on Rails: Talk
On 25 February 2016 at 21:03, Andrew Dig <li...@ruby-forum.com> wrote:
> already checked. nothing written in the log

When replying please quote the previous message, this is is a mailing
list not a forum (though you may be using it via a forum like
interface). If you don't we have to look back through previous
messages to find what you are replying to.

I presume that you mean that when you press the button absolutely
nothing happens at the server. In that case your submit button is not
working.

I notice that you seem to have a form that is a single row in a table,
that is not valid html. A form can wrap a complete table or exist
within a cell, but not wrap part of a table. That may or may not be
the problem you are seeing, but you must fix that first. Even if it
appeared to work it may not work in a different browser or a different
version of the same browser.

Colin

Andrew Dig

unread,
Feb 26, 2016, 2:44:45 AM2/26/16
to rubyonra...@googlegroups.com
Colin Law wrote in post #1181667:
Yes, you're right.I also noticed that but I guess if it was a main
reason that shouldn't work after page refresh but it worked....Whatever
I resolved a task via inline on-click handler(maybe a hack but works
properly)
Reply all
Reply to author
Forward
0 new messages