Tristan Kelley wrote:
> Hi all,
> Currently I am using Element.remove like so:
> 
> <div class="blurb" id="drag_1">
> <a onclick="Element.remove('drag_1');" class="remove"></a>
> </div>
> 
> However I would like to just create a function since I'll be removing
> multiple DIVs and updating the sortable order. I just can't get some
> version of Element.remove to target the parent DIV. I've tried several
> versions of this but no luck.
> 
> function removeParent() {
> var parentBlurb = document.getElementById().parentNode;
> Element.remove(parentBlurb);
> updateOrder();
> }

you need to tell it which element your operating on (getElementById() needs an
argument. Something like this:

function removeParent(el) {
  Element.remove(el.parentNode);
  updateOrder();
}

> <div class="blurb" id="drag_1">
> <a onclick="removeParent();" class="remove"></a>
> </div>

Then use it like this

<div class="blurb" id="drag_1">
  <a onclick="removeParent(this);" class="remove"></a>
</div>

-- 
Michael Peters
Developer
Plus Three, LP

_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to