Jeff,

First off... Wow, that's a long message and I had to read it a few times,
but I think I know what you're looking for!

>What I would like to do is identify some jQuery(?) variable that would
>allow me to bracket some code in the findValue() function, so that if
>the field value being evaluated is from unit lookup, it runs, and if
>it isn't it doesn't. I need to have a way to eliminate duplicate
>lookup selections for the select control, and I was considering
>looping through the select options in findValue() to see if the option
>existed before allowing them to add it.  In other words, I would like
>to avoid having to create a separate instance of findValue() and maybe
>the other functions for each field, if there is a way to do this. I
>have been mucking around in Firebug and I can't find anything. Does
>this make sense?  Know of a way to do this?

What you could do is look through the callbacks in the source code and add
the "input" variable as a second argument. So for example, you'd change the
line:

if( options.onFindValue ) setTimeout(function() { options.onFindValue(li) },
1);

To:
if( options.onFindValue ) setTimeout(function() { options.onFindValue(li,
input) }, 1);

This would pass a reference to the current input DOM element, so you could
do: 

if( input.id == "unit_lookup" ) alert("Ok, do something!");

This would also allow you to attach the behavior to multiple elements w/the
same call.

>Secondly, I see the dataset values returned from the ajax call in the
>response header using Firebug, but can't figure out a way to access
>them. I don't know where these go, but they don't appear to be in the
>DOM.  I was trying to come up with a way to loop through the query
>result values and compare them against the previous options already
>added to the select menu, and not allow them to display in the
>unit_lookup list if they already exist. Don't know if this is possible
>or not.

To solve the problem of not including items in the drop down, that might
already exist elsewhere in your code, what I'd recommend doing is modifying
the dataToDom() function. 

What I do is add a callback up you could use to determine if you want to
process the current row.

I'd change the "for" loop to something like:

var bProcessRow;
for (var i=0; i < num; i++) {
        var row = data[i];

        if( options.onProcessData ) var bProcessRow =
options.onProcessData(row);
        else bProcessRow = true;

        if( bProcessRow ){
                // insert existing logic here

        }
}

Doing this, you could create a callback function which would return
true/false on whether the current row should be added to the drop down. The
callback function would receive an array of all the items in the row from
the current data.

Hope this helps!

-Dan

Reply via email to