Austin,

I'm actually working on something just like that right now with some jQuery
guys.

IM me off-list at outlookeic (AIM) or [EMAIL PROTECTED] (GTalk).

-- Yehuda

On 1/16/07, Austin Schutz <[EMAIL PROTECTED]> wrote:

        I'm a newb to the list, so hello to all the people who have posted
to the list and made the list archives so helpful the last month or two!

        I'm trying to understand the use of OOP with jQuery. In creating
a fairly complex web application I have made extensive use of the class
attribute. Further, I've been successful in binding events to the classes,
setting styles, and that sort of thing.
        What I have not had much luck with is the creation of class
attributes
or methods. I simply don't understand the technique, and this seems to be
the one spot where the (really great!) docs are a bit sparse.

        For example, let's say I have a doctor's office, and want to track
patients. My html would look something like:

<div id='patient' class='Patient'>
<input id="address" type="textfield" class="PatientData" />
<select id="sex" class="PatientData">
  <option value="M">Male</option>
  <option value="F">Female</option>
</select>
</div>
<div id='spouse' class='Patient'>
<input id="address" type="textfield" class="PatientData" />
<select id="sex" class="PatientData">
  <option value="M">Male</option>
  <option value="F">Female</option>
</select>
</div>

        And the DOM would look something like:

<div>
  <input>
  <select>
     <option>
     <option>
<div>
  <input>
  <select>
     <option>
     <option>

        .. and now I can operate on those elements.

        What I want to do is create have a jquery enabled Patient
javascript
class which has methods and attributes I can access, and have the patient
div be an instance of that class. That will make it possible to do
something
like $('#spouse').getHomeAddress().

        Ideally it would be possible to use subclasses, and have the DOM
children be accessible as attributes, etc.

        The docs suggest extend() can be used for this, but the
methodology
isn't clear to me. That is, I _know_ I can extend jquery, and understand
more or less how the plugins work, but I don't understand how to relate
_elements_ to subclassed jquery classes. I don't just want to crap a bunch
of methods and attributes into the jQuery class itself.

        Uh, did that make any sense? :-)

        Thanks,
        Austin

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/




--
Yehuda Katz
Web Developer | Wycats Designs
(ph)  718.877.1325
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to