Hi all,
I am dynamically creating an item list with div containers. Because of
this dynamic nature, I am using the element.observe method along with
the bindAsEventListener() function to bind its execution to within the
object that creates the div in the first place.

The problem is that the POS argument I am passing along with it is
forever being bound to that element. This is causing a problem when I
create the functions for ordering the list (up/down). I can reorder
them, but the id stays with that element so that clicking on the up
button for one element causes a different element to move. Here is my
stripped down code for your viewing pleasure.

// FEATUREDCONTENT OBJECT
     featuredcontent = Class.create({

                        initialize: function(name) {
                                this.name = name;
                                this.place = -1;
                                this.FCArray = new Array(0);
                        },

          addElement: function(id,headline) {
               upf = (function (pos) {
                    // Create div -> link -> img
 
upLink.observe('click',this.upArticle.bindAsEventListener(this,pos));
                    return upLink;
               }).bind(pos);
               div.appendChild(upf(div.id));
          },

          upArticle: function(pos) {
                var before = this.FCArray[pos-1];
                this.FCArray.splice(pos-1,1);
                this.FCArray.splice(pos,0,before)
                var div = $('selected').childElements()[pos];
                div.id = pos-1;
                var divBefore = div.previous().insert({before: div});
                divBefore.id = pos;
          }
)}

The user selects from some articles, which populates a 'selected'
list. Each of these gets an up/down/delete function. So, again, the
problem is that the POS argument is for ever bound to the created
element.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to rubyonrails-spinoffs@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to