On Sep 24, 10:36 pm, pbd22 <dush...@gmail.comwrote:
In my script the below code creates a new element
The code below uses what must be a function named "Element" to create
a javascript object, though the fate of that object is unclear form
the code. If here you are referring to a DOM node implementing the
Element interface being created as a side effect (or anything else)
there is no evidence of that happening in this code.
on the page with an associated delete button:
var row_element = new Element(
'div',
{
'class':'container',
'events':{
'click':function( uid ){
this.activeRow( uid );
}.pass( current_element.uid, this )
}
}
).adopt( delete_button ).adopt( item );
Now, when a user clicks on that element,
Which element? You can "click on" (at least most) DOM Elements, but
"clicking" is a little detached from being something that you can do
with a javascript object.
I want the input fields on the page
What input fields, what page?
to be particular to that element.
So, whatever is written in them, gets stored in an array
that is specific to this particular element "uid". If something
was written, the fields get repopulated when the element
is clicked on again.
That sounds more like you want the contents of an INPUT (presumably
type="text") Element to change when some notion of 'current selection'
is applied to one of some group of other Elements by the action of
clicking.
Here is the function that gets activated when the element is clicked
on:
activeRow:function( uid ){
active_row = this.elements[ this.uid_lookup[ uid ] ];
[?]
}
How does it "get activated"? As javascript determines the - this -
value by how a function is called that is very important in
determining how this might behave, or be written so that it does
something related to what you are interested in.
I am not quite sure how to approach this, help appreciated.
The best approach to getting a question answered is to provide the
information necessary to answer it (and not hide it in anything
superfluous). Here you have provided none of the mark-up with which
this code is going to interact, you have not shown the context in
which the first code snippet is executed, your have not shown the
context in which the second is defined, you have not provided the
definition of the - Element - constructor used here, the - adopt -
method or the constructed/returned object (or the - adopt - method of
the object returned from the first call to - adopt -(if they differ)),
the - pass - method that appears to have been added to the -
Function.prototype -, or any of the code that these may depend upon.
There is no indication of the type or nature of the - uid - value or
the - current_element - value.