Ram
2009-Aug-06 11:51 UTC
2 onchange functions - 1 jquery, 1 prototype - not working in safari
Hi all, Im using the jNice plugin on a select box in a form of mine. Im also calling a custom JS function which uses prototype on the same select box. <%= f.collection_select :item_name, Item.all, :item_for_order, :name, { :name => "select", :onchange => "item_row($(this));"} %> now both jNice and item_row() work in FF when i change the selected value. But it does not work in Safari. In safari, the page jumps to the top when i click on a selection, if i click on it again, jNice works. item_row() does not. Now im not sure what the problem is. Im using jQuery.noConflict to avoid conflict between the two libraries and otherwise, the JS heavy page is working fine. Anyone with any experience/ tips on this one? Vinay.
Ram
2009-Aug-07 04:35 UTC
Re: 2 onchange functions - 1 jquery, 1 prototype - not working in safari
i narrowed down the issue to one line of code in the item_row function. it tries to insert a value into a hidden_field which is kind of hanging inside <tr> tags. Here''s the HTML and JS code.. HTML --------- <tr class="row"> <td>....</td> <td>....</td> <input class="item_id" id="order_item_id" name="order[item_id]" type="hidden" /> <td> <%= f.collection_select :item_name, Item.all, :item_for_order, :name, { :name => "select", :onchange => "item_row($(this));"} %> </td> </tr> JS ---- function item_row(element){ .... id = /* calculation excluded for brevity */ (element).up(''.row'').down(''.item_id'').value = id ; //this is the line that fails in safari but works in FF .... } Anything wrong with my HTML structure that Safari is rejecting? thanks. On Aug 6, 4:51 pm, Ram <yourstruly.vi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all, > > Im using the jNice plugin on a select box in a form of mine. Im also > calling a custom JS function which uses prototype on the same select > box. > > <%= f.collection_select :item_name, Item.all, :item_for_order, :name, > { :name => "select", :onchange => "item_row($(this));"} %> > > now both jNice and item_row() work in FF when i change the selected > value. But it does not work in Safari. In safari, the page jumps to > the top when i click on a selection, if i click on it again, jNice > works. item_row() does not. > > Now im not sure what the problem is. Im using jQuery.noConflict to > avoid conflict between the two libraries and otherwise, the JS heavy > page is working fine. > > Anyone with any experience/ tips on this one? > > Vinay.
nirosh
2009-Aug-07 05:28 UTC
Re: 2 onchange functions - 1 jquery, 1 prototype - not working in safari
hi i faced the similar prob b4 1 month and then i find out this solution cange the function from onchange to onclick. this onchange not works with IE7 as well.ff works perfectly. nirosh On Aug 7, 9:35 am, Ram <yourstruly.vi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> i narrowed down the issue to one line of code in the item_row > function. it tries to insert a value into a hidden_field which is kind > of hanging inside <tr> tags. Here''s the HTML and JS code.. > > HTML > --------- > <tr class="row"> > <td>....</td> > <td>....</td> > <input class="item_id" id="order_item_id" name="order[item_id]" > type="hidden" /> > <td> > <%= f.collection_select :item_name, > Item.all, :item_for_order, :name, { :name => "select", :onchange => > "item_row($(this));"} %> > </td> > </tr> > > JS > ---- > function item_row(element){ > .... > id = /* calculation excluded for brevity */ > (element).up(''.row'').down(''.item_id'').value = id ; //this is the > line that fails in safari but works in FF > .... > > } > > Anything wrong with my HTML structure that Safari is rejecting? > > thanks. > > On Aug 6, 4:51 pm, Ram <yourstruly.vi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi all, > > > Im using the jNice plugin on a select box in a form of mine. Im also > > calling a custom JS function which uses prototype on the same select > > box. > > > <%= f.collection_select :item_name, Item.all, :item_for_order, :name, > > { :name => "select", :onchange => "item_row($(this));"} %> > > > now both jNice and item_row() work in FF when i change the selected > > value. But it does not work in Safari. In safari, the page jumps to > > the top when i click on a selection, if i click on it again, jNice > > works. item_row() does not. > > > Now im not sure what the problem is. Im using jQuery.noConflict to > > avoid conflict between the two libraries and otherwise, the JS heavy > > page is working fine. > > > Anyone with any experience/ tips on this one? > > > Vinay.
Vinay Seshadri
2009-Aug-07 05:31 UTC
Re: 2 onchange functions - 1 jquery, 1 prototype - not working in safari
I actually just solved it by putting the hidden_field inside another <td> instead of leaving it hanging outside. I have not checked in IE7. thanks for the heads-up! :) 2009/8/7 nirosh <kunalan.kandiah-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> > hi > i faced the similar prob b4 1 month and then i find out this solution > cange > the function from onchange to onclick. this onchange not works with > IE7 > as well.ff works perfectly. > > nirosh > > On Aug 7, 9:35 am, Ram <yourstruly.vi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > i narrowed down the issue to one line of code in the item_row > > function. it tries to insert a value into a hidden_field which is kind > > of hanging inside <tr> tags. Here''s the HTML and JS code.. > > > > HTML > > --------- > > <tr class="row"> > > <td>....</td> > > <td>....</td> > > <input class="item_id" id="order_item_id" name="order[item_id]" > > type="hidden" /> > > <td> > > <%= f.collection_select :item_name, > > Item.all, :item_for_order, :name, { :name => "select", :onchange => > > "item_row($(this));"} %> > > </td> > > </tr> > > > > JS > > ---- > > function item_row(element){ > > .... > > id = /* calculation excluded for brevity */ > > (element).up(''.row'').down(''.item_id'').value = id ; //this is the > > line that fails in safari but works in FF > > .... > > > > } > > > > Anything wrong with my HTML structure that Safari is rejecting? > > > > thanks. > > > > On Aug 6, 4:51 pm, Ram <yourstruly.vi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi all, > > > > > Im using the jNice plugin on a select box in a form of mine. Im also > > > calling a custom JS function which uses prototype on the same select > > > box. > > > > > <%= f.collection_select :item_name, Item.all, :item_for_order, :name, > > > { :name => "select", :onchange => "item_row($(this));"} %> > > > > > now both jNice and item_row() work in FF when i change the selected > > > value. But it does not work in Safari. In safari, the page jumps to > > > the top when i click on a selection, if i click on it again, jNice > > > works. item_row() does not. > > > > > Now im not sure what the problem is. Im using jQuery.noConflict to > > > avoid conflict between the two libraries and otherwise, the JS heavy > > > page is working fine. > > > > > Anyone with any experience/ tips on this one? > > > > > Vinay. > > >-- In Sport We Trust !!! --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Aug-07 08:34 UTC
Re: 2 onchange functions - 1 jquery, 1 prototype - not working in safari
On Aug 7, 5:35 am, Ram <yourstruly.vi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Anything wrong with my HTML structure that Safari is rejecting? >You shouldn;t have an input element there - The direct children of a tr tag should only be td tags (or similar (th etc.)) Fred> thanks. > > On Aug 6, 4:51 pm, Ram <yourstruly.vi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi all, > > > Im using the jNice plugin on a select box in a form of mine. Im also > > calling a custom JS function which uses prototype on the same select > > box. > > > <%= f.collection_select :item_name, Item.all, :item_for_order, :name, > > { :name => "select", :onchange => "item_row($(this));"} %> > > > now both jNice and item_row() work in FF when i change the selected > > value. But it does not work in Safari. In safari, the page jumps to > > the top when i click on a selection, if i click on it again, jNice > > works. item_row() does not. > > > Now im not sure what the problem is. Im using jQuery.noConflict to > > avoid conflict between the two libraries and otherwise, the JS heavy > > page is working fine. > > > Anyone with any experience/ tips on this one? > > > Vinay.
Vinay Seshadri
2009-Aug-07 08:42 UTC
Re: 2 onchange functions - 1 jquery, 1 prototype - not working in safari
Hmmm.. this is what I have now. Is this ok? <tr class="row"> <td> <input class="item_id" id="order_item_id" name="order[item_id]" type="hidden" /> .... </td> <td>....</td> <td> <%= f.collection_select :item_name, Item.all, :item_for_order, :name, { :name => "select", :onchange => "item_row($(this));"} %> </td> </tr> 2009/8/7 Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> > > On Aug 7, 5:35 am, Ram <yourstruly.vi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Anything wrong with my HTML structure that Safari is rejecting? > > > > You shouldn;t have an input element there - The direct children of a > tr tag should only be td tags (or similar (th etc.)) > > Fred > > > thanks. > > > > On Aug 6, 4:51 pm, Ram <yourstruly.vi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > Hi all, > > > > > Im using the jNice plugin on a select box in a form of mine. Im also > > > calling a custom JS function which uses prototype on the same select > > > box. > > > > > <%= f.collection_select :item_name, Item.all, :item_for_order, :name, > > > { :name => "select", :onchange => "item_row($(this));"} %> > > > > > now both jNice and item_row() work in FF when i change the selected > > > value. But it does not work in Safari. In safari, the page jumps to > > > the top when i click on a selection, if i click on it again, jNice > > > works. item_row() does not. > > > > > Now im not sure what the problem is. Im using jQuery.noConflict to > > > avoid conflict between the two libraries and otherwise, the JS heavy > > > page is working fine. > > > > > Anyone with any experience/ tips on this one? > > > > > Vinay. > > >-- In Sport We Trust !!! --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Vinay Seshadri
2009-Aug-07 09:00 UTC
Re: 2 onchange functions - 1 jquery, 1 prototype - not working in safari
Im actually having another interesting issue with this table structure im having. I provide a link to add another row to the table. The structure is like this.. HTML --------- <table id="tab"> <tr> <!-- SOME <td>s HERE --> </tr> <%= render :partial => "item", :collection => @order.items %> <tr onmouseover="document.getElementById(''plussign'').style.display=''block'';" onmouseout="document.getElementById(''plussign'').style.display=''none'';" id="empty_record"> <td> <div style="display:none;" id="plussign"><%= add_item_link "+" %></div> </td> <!-- MORE <td>s HERE --> </tr> <!-- MORE <tr>s HERE --> </table> _item.html.erb --------------------- <tr class="row"> <!-- <td>s HERE --> </tr> helper method --------------------- def add_item_link(name) link_to_function name do |page| page.insert_html :bottom, :items, :partial=>''item'', :object => Item.new end end I was using this successfully when my structure was all in <div>s. I just inserted a container div with id ''items'' at the bottom of which i wanted the new item row. now i cant use <div>s in between. How can I achieve this functionality? Any ideas? thanks.. 2009/8/7 Vinay Seshadri <yourstruly.vinay-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> Hmmm.. this is what I have now. Is this ok? > <tr class="row"> > <td> > <input class="item_id" id="order_item_id" > name="order[item_id]" type="hidden" /> > .... > </td> > <td>....</td> > > <td> > <%= f.collection_select :item_name, > Item.all, :item_for_order, :name, { :name => "select", :onchange => > "item_row($(this));"} %> > </td> > </tr> > > 2009/8/7 Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > >> >> On Aug 7, 5:35 am, Ram <yourstruly.vi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > >> > Anything wrong with my HTML structure that Safari is rejecting? >> > >> >> You shouldn;t have an input element there - The direct children of a >> tr tag should only be td tags (or similar (th etc.)) >> >> Fred >> >> > thanks. >> > >> > On Aug 6, 4:51 pm, Ram <yourstruly.vi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > >> > >> > >> > > Hi all, >> > >> > > Im using the jNice plugin on a select box in a form of mine. Im also >> > > calling a custom JS function which uses prototype on the same select >> > > box. >> > >> > > <%= f.collection_select :item_name, Item.all, :item_for_order, :name, >> > > { :name => "select", :onchange => "item_row($(this));"} %> >> > >> > > now both jNice and item_row() work in FF when i change the selected >> > > value. But it does not work in Safari. In safari, the page jumps to >> > > the top when i click on a selection, if i click on it again, jNice >> > > works. item_row() does not. >> > >> > > Now im not sure what the problem is. Im using jQuery.noConflict to >> > > avoid conflict between the two libraries and otherwise, the JS heavy >> > > page is working fine. >> > >> > > Anyone with any experience/ tips on this one? >> > >> > > Vinay. >> >> >> > > > -- > In Sport We Trust !!! >-- In Sport We Trust !!! --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---