mysql - Help with executing javascript through ajax via ror -
I am quite new to Rail on Ruby and I need to help with some building and Ajax code execution.
Currently there is an invitation function in my webpage which does not work very well. I share the code in a minute, but what it currently describes to me, and what I am trying to do. Therefore, the way the work has been invited is currently:
There are 2 buttons to invite people to a page created by a user, a button for those on the site Not yet registered and there are other buttons for registered people on the site. In this current setup, the user needs to know that whether the person who is inviting is a registered user or not (as you can say that this is a big drawback). This code looks like this:
This code executes in that AJAX (I'm using HAML along the way, and can post more codes if needed): < Pre> This code is in the application.js file: I want to apply it: I have a text field with a new function And want to create a button.The user will input the email of the person who wants to invite them to the new textfield and then click on the new button. This new button is a new The trigger will trigger: The new function will compare email based on email (probably where sql function) registered in the textfield, and on the basis of whether the user exits or not (i.e .: Email in Textbox Match And email in the database) through this statement will already execute an existing work. Unfortunately I do not know how to do it properly What is the problem, but it is not working: In this view: : Any help would be greatly appreciated I have time to read your question Thank you for removing, and if you need clarification on some (I know that maybe I am doing a bad thing by explaining it in sufficient detail) Please do not hesitate to ask! Thank you again! It seems that you are matching the rail code in application.js And this is not a number. You should prepare your controller for a JS request with a You should also check. .invitepeople_buttons = button_to_function 'Add existing user', 'insert_add_existing_member_form ()',: class = & gt; "Submit" = Button_to_function 'Add new user', 'insert_invitation_membership_form ()' ,: class = & gt; "Floatright submit"
var insert_invitation_membership_form = function () {$ ('# membership_form_footer'). ("& Lt; h2 & gt; add new user & lt; / h2 & gt;") var template = $ ("# invitation_mishhip_print"). Clone () $ ("# member_number_peter"). (Replace template.html (replace / new_membership ("& lt; h2 & gt; add current user & lt; / h2 & gt;") template = $ (/) ("Source_member_autocomplete '). (Autocomplete ({Source: users_for_autocomplete, select: function (event, ui)) (Ui.item)}}}}
.invitepeople_buttons = text_field "member_email", "" = button_to_function 'add members' 'Test_email_for_membership ()',: class = & gt; Application.js in the "Submit"
var test_email_for_membership = function () {if user.where (: email = & gt; member_email). Present? First ("& lt; h2 & gt; add existing user & lt; / h2 & gt;") template = $ ("# add_existing_member_form"). Clone () $ ("#smount_former") Template.html ()) $ ('current_member_autocomplete'). Autocomplete ({source: users_for_autocomplete, select: function (event, ui) {insert_membership_form (ui.item)}}) Other $ ('# membership_form_footer') "& Lt; h2 & gt; add new user & lt; / h2 & gt;") var template = $ ("# invitation_mishhip_product"). Clone () $ ("# member_number_peter"). (Template.html () before (/ new_membership / g, new date). GetTime ())}
You should check the controller to trigger with Ajax request (easy) to check that the user already exists and then perform your choice of work based on your feedback. response_to block. Potential Solution:
Do not Answer | Format | Format.js If user.where ('email =?', Params [: Email]). May first render: text = & gt; "truth" and presented: text = & gt; End of the "false" end of end
Comments
Post a Comment