Hey Champs.. Can we write some ruby code into javascript ? Can you guys light me? -- 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 30 March 2010 12:25, Hemant Bhargava <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hey Champs.. > > Can we write some ruby code into javascript ?Do you mean that within some javascript can you use Ruby? If you mean that then this would be difficult. The ruby code is run in the server which is where ruby is installed. Javascript is run in the users PC in the browser. Colin -- 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.
Colin Law wrote:> Do you mean that within some javascript can you use Ruby? If you mean > that then this would be difficult. The ruby code is run in the server > which is where ruby is installed. Javascript is run in the users PC > in the browser.Hi Colin, only u come when i asks anybody for help .. :) Thanks. Anyway my situation is that i have a gem installed on my machine "calender_date_select" and i am dynamically populating the fields using javascript.. Now i also need to create a text-box with calendar with javascript.. Ordinarily, this is the way we use calendar_date_select:- <%= calendar_date_select :abc, :def, :year_range => 1.years.ago..1.years.since, %> Can we write it in javascript.. -- 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 30 March 2010 13:07, Hemant Bhargava <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote: >> Do you mean that within some javascript can you use Ruby? If you mean >> that then this would be difficult. The ruby code is run in the server >> which is where ruby is installed. Javascript is run in the users PC >> in the browser. > > Hi Colin, only u come when i asks anybody for help .. :) Thanks.Glad to be of help> > Anyway my situation is that i have a gem installed on my machine > "calender_date_select" and i am dynamically populating the fields using > javascript.. Now i also need to create a text-box with calendar with > javascript.. Ordinarily, this is the way we use calendar_date_select:- > <%= calendar_date_select :abc, :def, :year_range => > 1.years.ago..1.years.since, %>You can do anything you like in javascript that you can do on any web page. What do you mean by "create a text-box with calendar". Colin -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
While using calendar_date_select, it appers like this .. i mean usage of this gem.. <%= calendar_date_select :abc, :def, :year_range => 1.years.ago..1.years.since %>, it come like this TEXT_BOX(nameabc[def]) Button After clicking on button a calendar popups and whatever date i select comes in the text box.. So in web page i am doing it like this only but how should i do this in javascript.. I am little bit confused..> You can do anything you like in javascript that you can do on any web > page. What do you mean by "create a text-box with calendar". > > Colin-- 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 31 March 2010 06:43, Hemant Bhargava <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> While using calendar_date_select, it appers like this .. i mean usage of > this gem.. > > <%= calendar_date_select :abc, :def, :year_range => > 1.years.ago..1.years.since %>, it come like this > > TEXT_BOX(nameabc[def]) Button > > After clicking on button a calendar popups and whatever date i select > comes in the text box.. So in web page i am doing it like this only but > how should i do this in javascript.. I am little bit confused..I have not used calendar_date_select but I imagine it is already using javascript to do the popup. Have a look at the html of your page and see what is there. (View, Page Source or similar in browser). Colin -- 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.
Colin Law wrote:> On 31 March 2010 06:43, Hemant Bhargava <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> how should i do this in javascript.. I am little bit confused.. > I have not used calendar_date_select but I imagine it is already using > javascript to do the popup. Have a look at the html of your page and > see what is there. (View, Page Source or similar in browser). > > ColinSource code for line <%= calendar_date_select :abc, :def, :year_range => 1.years.ago..1.years.since, %> is as:- <input id="abc_def" type="text" value="" size="30" name="abc[def]"/> <img class="calendar_date_select_popup_icon" style="border: 0px none ; cursor: pointer;" src="/abc/images/calendar_date_select/calendar.gif?1266227981" onclick="new CalendarDateSelect( $(this).previous(), {year_range:[2009, 2011]} );" alt="Calendar"/> How should i write this code in javascript.. I tried it but fails.. -- 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 31 March 2010 09:04, Hemant Bhargava <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote: >> On 31 March 2010 06:43, Hemant Bhargava <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> how should i do this in javascript.. I am little bit confused.. >> I have not used calendar_date_select but I imagine it is already using >> javascript to do the popup. Have a look at the html of your page and >> see what is there. (View, Page Source or similar in browser). >> >> Colin > > Source code for line > > <%= calendar_date_select :abc, :def, :year_range => > 1.years.ago..1.years.since, %> > > is as:- > > <input id="abc_def" type="text" value="" size="30" name="abc[def]"/> > <img class="calendar_date_select_popup_icon" style="border: 0px none ; > cursor: pointer;" > src="/abc/images/calendar_date_select/calendar.gif?1266227981" > onclick="new CalendarDateSelect( $(this).previous(), {year_range:[2009, > 2011]} );" alt="Calendar"/> > > How should i write this code in javascript.. I tried it but fails..I don''t understand what you mean when you say you want to write it in javascript. Colin -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hello, if you define your Javascript function in your "html.erb" (and not on a external file) you could just use <%= ... %> to access ruby predefined variables and on ruby you would write that code in to a string and then use it. but the calendar_date_select controle pretty much covers all the javascript needed for it to work...you just have to put it one the page. regs. On Wed, Mar 31, 2010 at 9:04 AM, Hemant Bhargava <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> Colin Law wrote: > > On 31 March 2010 06:43, Hemant Bhargava <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > >> how should i do this in javascript.. I am little bit confused.. > > I have not used calendar_date_select but I imagine it is already using > > javascript to do the popup. Have a look at the html of your page and > > see what is there. (View, Page Source or similar in browser). > > > > Colin > > Source code for line > > <%= calendar_date_select :abc, :def, :year_range => > 1.years.ago..1.years.since, %> > > is as:- > > <input id="abc_def" type="text" value="" size="30" name="abc[def]"/> > <img class="calendar_date_select_popup_icon" style="border: 0px none ; > cursor: pointer;" > src="/abc/images/calendar_date_select/calendar.gif?1266227981" > onclick="new CalendarDateSelect( $(this).previous(), {year_range:[2009, > 2011]} );" alt="Calendar"/> > > How should i write this code in javascript.. I tried it but fails.. > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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.
Thanks colin and Rui.. I made it worked.. I copied the code from page source and give it to the onclick of the text box. Earlier also, i was donig the same but a variable was not there. So fixed it and worked like a charm.. Thanks again.. Colin Law wrote:> On 31 March 2010 09:04, Hemant Bhargava <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> >> 2011]} );" alt="Calendar"/> >> >> How should i write this code in javascript.. I tried it but fails.. > > I don''t understand what you mean when you say you want to write it in > javascript. > > Colin-- 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 Mar 30, 12:44 pm, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> Do you mean that within some javascript can you use Ruby? If you mean > that then this would be difficult. The ruby code is run in the server > which is where ruby is installed. Javascript is run in the users PC > in the browser. >I doubt this is what was being asked but there is a an implementation of ruby in javascript (hotruby) Fred -- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hemant Bhargava wrote:> Hey Champs.. > > Can we write some ruby code into javascript ? > > Can you guys light me?you can make a main_scripts.js.erb inside one of your views then you can mix in ruby and JS together. The ruby will be processed first, and then made into a static js file, then you can include that. OR, you can do inline JS in your views (it''s yucky though :p ). You could also get crazy and include the Johnson gem and then get some crazy ruby generating JS on the fly stuff. Good luck! ~Jeremy -- 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.