Any recommendations?  ;)

My stumbling block is the following:

I have a masking function that lets you define a mask for an input field:
$("#myInput").fieldMask("(999) 999-9999")  This lets me force an input into
a certain pattern.  At the moment I have a root global object which is just
a place to store data about the mask, though I have the masking functions
attached to that object as well.  My problem is that this object is not
related to the input field in any way.  From what I know about objects, I
think it makes more sense to create a prototype for the object then create
an instance for each form field but I am not sure how I would get there from
here.

Currently, I initialize all the fields that have masks using a setMask()
function which creates a node in my global object for each field so I can
store values between keystrokes.  I have a function in my global object
called doMask(ele) which gets called from the input field's keyup event and
gets passed "this".  Then I extract the ID and use it to reference the node
for this element (var t = daemach.fieldMask.nodes[ele.id];)  I then have to
pass that variable to my masking functions.

If I create an object instance for each field, I should be able to do
something like this.node from inside all my functions instead of having to
pass the reference.  I know this.

My problem is this:  If I have 10 fields that need to be masked and thereby
10 object instances, how do I call THAT field's instance from inside its
keyup event?



On 3/23/07, Jörn Zaefferer <[EMAIL PROTECTED]> wrote:

Daemach schrieb:
> I have no formal programming training, so I often brute-force things
> that could be a lot more elegant.  One thing I'm struggling with in
> particular now is the benefits of creating object prototypes over just
> storing data in a global tree.  A few people on this list have taken a
> shot at explaining some of this to me, and thank you very much for
> that, but it's just not sinking in which is unusual and frustrating.
>
> Can you all tell us what books are good for advanced Javascript
> reference?  Closures, objects, advanced functions, etc.  I've been
> doing DOM programming long enough that I can find a way around pretty
> much every problem but I want to take my game to the next level.
>
> Your help is much appreciated!!
You may want to try books about object-oriented programming. Working
with a object-oriented language alone doesn't make you an oo-programmer,
eg. you can programm fully procedural programs with Java. Once you get
the idea why packaging data with behaviour is good, you should be able
to find your way around JavaScript better.

--
Jörn Zaefferer

http://bassistance.de


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to