Hi all, Is there a way to use Insert.Top with a div''s class instead of the id? I''ve tried a couple things, including a combination of document.getElementsByClassName and Insert.Top but just can''t get it working. Thanks again!
If it''s only one div you want to use, this should work: new Insertion.Top($$("div.someClass").first(), ''content here''); if you want to change all divs with a specific class name: $$("div.someClass").each(function(element) { new Insertion.Top(element, "new content here"); }); Martin, burnfield.com/martin On 7/26/06, Tristan Kelley <tristankelley-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all, > > Is there a way to use Insert.Top with a div''s class instead of the id? > I''ve tried a couple things, including a combination of > document.getElementsByClassName and Insert.Top but just can''t get it > working. Thanks again! > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >
Thanks for the info Martin! One thing that I''m having some trouble with is that the DIV that I''m inserting is a drag handle for a sortable. Everything works fine untill I insert a new sortable then all of the drag handles stop working (except for the one on the draggable that was inserted). Not too sure what is going on. Here''s some of the code. Thanks. ///function to insert new draggable/// function xxxNew(url) { myAjax = new Ajax.Request(url, { method : ''get'', onComplete : function (ajax){ element = new Insertion.Top(''left_column'', ajax.responseText); startDragging(); updateRanking(); } }); } ///start dragging/sorting/// function startDragging() { $$("div.blurb").each(function(element) { new Insertion.Top(element, "<div class=\"drag\" title=\"Move this item to a new position\"></div>"); }); // <![CDATA[ sections = [''left_column'',''right_column'']; Sortable.create(''left_column'',{tag:''div'',dropOnEmpty: true,handle:''drag'', only:''blurb'',scroll: window, onUpdate:updateRanking}); Sortable.create(''right_column'',{tag:''div'',dropOnEmpty: true,handle:''drag'', only:''blurb'',scroll: window, onUpdate:updateRanking}); // ]]> } On 7/27/06, Martin Ström <martinstromlists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> If it''s only one div you want to use, this should work: > > new Insertion.Top($$("div.someClass").first(), ''content here''); > > if you want to change all divs with a specific class name: > > $$("div.someClass").each(function(element) { > new Insertion.Top(element, "new content here"); > }); > > > Martin, > > burnfield.com/martin > > On 7/26/06, Tristan Kelley <tristankelley-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi all, > > > > Is there a way to use Insert.Top with a div''s class instead of the id? > > I''ve tried a couple things, including a combination of > > document.getElementsByClassName and Insert.Top but just can''t get it > > working. Thanks again! > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >
Any ideas on this one? I still haven''t gotten it sorted out. Please see my post below. Thanks all! On 7/27/06, Tristan Kelley <tristankelley-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: Thanks for the info Martin! One thing that I''m having some trouble with is that the DIV that I''m inserting is a drag handle for a sortable. Everything works fine untill I insert a new sortable then all of the drag handles stop working (except for the one on the draggable that was inserted). Not too sure what is going on. Here''s some of the code. Thanks. ///function to insert new draggable/// function xxxNew(url) { myAjax = new Ajax.Request(url, { method : ''get'', onComplete : function (ajax){ element = new Insertion.Top(''left_column'', ajax.responseText); startDragging(); updateRanking(); } }); } ///start dragging/sorting/// function startDragging() { $$("div.blurb").each(function(element) { new Insertion.Top(element, "<div class=\"drag\" title=\"Move this item to a new position\"</div"); }); // <![CDATA[ sections = [''left_column'',''right_column'']; Sortable.create(''left_column'',{tag:''div'',dropOnEmpty: true,handle:''drag'', only:''blurb'',scroll: window, onUpdate:updateRanking}); Sortable.create(''right_column'',{tag:''div'',dropOnEmpty: true,handle:''drag'', only:''blurb'',scroll: window, onUpdate:updateRanking}); // ]] } On 7/27/06, Martin Ström <martinstromlists-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: If it''s only one div you want to use, this should work: new Insertion.Top($$("div.someClass").first(), ''content here''); if you want to change all divs with a specific class name: $$("div.someClass").each(function(element) { new Insertion.Top(element, "new content here"); }); Martin, burnfield.com/martin On 7/26/06, Tristan Kelley <tristankelley-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: Hi all, Is there a way to use Insert.Top with a div''s class instead of the id? I''ve tried a couple things, including a combination of document.getElementsByClassName and Insert.Top but just can''t get it working. Thanks again! _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs