When you click [x] the close button, will show the alert with 3 button
like below picture:
Show dialog message
================================================Do you want to save changes?
All details will be lost if you don''t save them.
Dont'' save | cancel | save
================================================
I am using jquery colorbox, the code as below:
<a class=''inline''
href="#inline_content">[X]</a>
<div style=''display:none''>
<div id=''inline_content'' style=''padding:10px;
background:#fff;''>
<b>Do you want to save changes?</b>
All details will be lost if you don''t save them.
<br/><br/>
<%= link_to "Don''t Save", main_screen_main_path
%> |
<a
href="javascript:parent.$.colorbox.close()">cancel</a> |
<%= submit_tag "save" %>
</div>
</div>
<script>
$(document).ready(function(){
$(".inline").colorbox({inline:true, width:"500"});
});
</script>
Problem:
When I click "Save" button, it does''t works...
What code should I write like :onsubmit => ?? ?
(I am weak for javascript)..
Thanks.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, Jan 12, 2012 at 12:23 AM, Joachim Cheng <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> > Problem: > When I click "Save" button, it does''t works... > What code should I write like :onsubmit => ?? ? > (I am weak for javascript).. > > Thanks. > >You are trying to save a form? Javier -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Javier Quarite wrote in post #1040503:> On Thu, Jan 12, 2012 at 12:23 AM, Joachim Cheng > <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote: > >> >> Problem: >> When I click "Save" button, it does''t works... >> What code should I write like :onsubmit => ?? ? >> (I am weak for javascript).. >> >> Thanks. >> >> > You are trying to save a form? > > > JavierYes, a page has many form to fill. when you click [x] close button, it appear the dialog as above. When I try to click ''save'' button, it won''t works.. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, Jan 12, 2012 at 12:04 PM, Joachim Cheng <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> > Yes, a page has many form to fill. when you click [x] close button, it > appear the dialog as above. When I try to click ''save'' button, it won''t > works.. > > -- >Well then, the easiest way of doing that is: * inside the function that grabs the "save" action $("#form_id").submit(); I''m not really sure the way colorbox works, what I gave works for example: <%= link_to "save", "#", :remote=>true, :onclick=>"save_with_click"%> function save_with_click(){ $("#form_id").submit(); } I think you can do the same with your submit button Javier -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Javier Quarite wrote in post #1040531:> On Thu, Jan 12, 2012 at 12:04 PM, Joachim Cheng > <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote: > >> >> Yes, a page has many form to fill. when you click [x] close button, it >> appear the dialog as above. When I try to click ''save'' button, it won''t >> works.. >> >> -- >> > > Well then, the easiest way of doing that is: > > * inside the function that grabs the "save" action > > $("#form_id").submit(); > > I''m not really sure the way colorbox works, what I gave works for > example: > > <%= link_to "save", "#", :remote=>true, :onclick=>"save_with_click"%> > > function save_with_click(){ > $("#form_id").submit(); > } > > I think you can do the same with your submit button > > JavierOk, I give you the simple code.. Hope you can teach me.. Thank you. Where should I place "form_id"?? <%= form_tag action_tasks_path do %> <table border="1"> <tr> <td colspan="3" align="right"> <a class=''inline'' href="#inline_content">[X]</a> <div style=''display:none''> <div id=''inline_content''> <b>Do you want to save changes made to this job?</b><br/> All details will be lost if you don''t save them. <br/><br/> <%= link_to "Don''t Save", main_home_path %> | <a href="javascript:parent.$.colorbox.close()">close</a> | <%= link_to "save", "#", :remote => true, :onclick => "save_with_click"%> </div> </div> </td> </tr> <script> $(document).ready(function(){ $(".inline").colorbox({inline:true, width:"500"}); }); function save_with_click(){ $("#form_id").submit(); } </script> </table> name: <%= text_field_tag :name, params[:name] %> Description: <%= text_area_tag :description, params[:description], :rows => 3 %> <% end %> -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, Jan 12, 2012 at 2:08 PM, Joachim Cheng <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> > Ok, I give you the simple code.. Hope you can teach me.. Thank you. > Where should I place "form_id"?? > > <%= form_tag action_tasks_path do %> > <table border="1"> > <tr> > <td colspan="3" align="right"> > <a class=''inline'' href="#inline_content">[X]</a> > <div style=''display:none''> > <div id=''inline_content''> > <b>Do you want to save changes made to this job?</b><br/> > All details will be lost if you don''t save them. > <br/><br/> > <%= link_to "Don''t Save", main_home_path %> | > <a href="javascript:parent.$.colorbox.close()">close</a> > | > <%= link_to "save", "#", :remote => true, :onclick => > "save_with_click"%> > </div> > </div> > </td> > </tr> > <script> > $(document).ready(function(){ > $(".inline").colorbox({inline:true, width:"500"}); > }); > function save_with_click(){ > $("#form_id").submit(); > } > </script> > </table> > > name: <%= text_field_tag :name, params[:name] %> > Description: > <%= text_area_tag :description, params[:description], :rows => 3 %> > <% end %> > >By form_id I meant the ID of the form (you can view that by checking the source code). I guess it is new_action_tasks, but this is an ID generated by rails, you can give it a value by sending it like ":id=> my_id" inside form_tag I suggest this cast http://railscasts.com/episodes/136-jquery I might give you an idea of what I''m saying :) Javier -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Javier, I think I don''t use colorbox now.. so, do you know to use jQuery Impromptu?? http://trentrichardson.com/Impromptu/index.php -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Yeah, I can do it.
<%= link_to "save", "#", :remote=>true,
:onclick=>"save_with_click"%>
function save_with_click(){
$("#form_id").submit();
}
change to:
<%= form_tag save_file_path, :id => ''mysubmitform'' do
%>
...
<a href="javascript:save();">save</a>
<script>
function save(){
$(''#mysubmitform'').submit();
return false;
}
</script>
...
<% end %>
This function can works for me!! I am using jquery colorbox.
Thank you, Javier.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sat, Jan 14, 2012 at 4:11 AM, Joachim Cheng <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Yeah, I can do it. > > <%= link_to "save", "#", :remote=>true, :onclick=>"save_with_click"%> > function save_with_click(){ > $("#form_id").submit(); > } > > change to: > > <%= form_tag save_file_path, :id => ''mysubmitform'' do %> > ... > > <a href="javascript:save();">save</a> > <script> > function save(){ > $(''#mysubmitform'').submit(); > return false; > } > </script> > > ... > <% end %> > > This function can works for me!! I am using jquery colorbox. > Thank you, Javier. > >Glad to hear that :) I tought you jus wanted to save it via AJAX that''s why I use that remote true, you can do that <a> label using rails. Also that :id=>"mysubmitform" may not be needed, just check the id of the form using a debugger (firebug in firefox or the one that comes in chrome). Javier -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.