On 1/19/07, Christopher Jordan <[EMAIL PROTECTED]> wrote:
[..]
>  I don't really understand how to use filters. You're the second or third
> person to mention them, and I did some reading yesterday, but I still don't
> completely understand. [...]

I'm not familiar with CF but I'm going to try and plugin the filter
code into the snippet of code you posted.


First replace this for loop:
    for(i = 0; i < myRecordCount; i++){
        myShiftDate = "{ts '" +
CFJS.ListFirst(FlexOrderData.data.SHIFTDATE[i],".") + "'}";
        mySelector = "[EMAIL PROTECTED]" + myShiftDate + "]";
        myjQueryString = CFJS.ListAppend(myjQueryString, mySelector);
    }


With this new for loop:
        var myShiftDates = [];
        for(var i=0; i<myRecordCount; i++)
                myShiftDates.push("{ts '" +
CFJS.ListFirst(FlexOrderData.data.SHIFTDATE[i],".") + "'}");



Next replace this set of code:
    alert("done with first loop");
    myDiv = $(".CalendarWrapper");
    eval("myCells = $(\"" + myjQueryString + "\", myDiv);");
    alert("done with second evaluation");


    for(i = 0; i < myCells.length; i++){
        myCalendarCell = $(myCells[i]);
        myShiftDate = myCalendarCell.attr("dateValue");
        myTempDate = $.odbcDateTimeParse(myShiftDate);
        myBackgroundColor = "#ThisWeekdayColor#";
        if(!(myTempDate.getDay() % 6)){
            myBackgroundColor = "#ThisWeekendColor#";
        }
        
myCalendarCell.removeClass("CalendarCellDisabled").addClass("CalendarCellEnabled").attr("state",
"Enabled").css({background:myBackgroundColor,
color:"#ThisFlexOrderEntryNormalTextColor#"});
        <CFIf ParameterExists(ThisSelectedDate)>
            if("#ThisSelectedDate#" == myShiftDate){
                CalendarEvents(myCalendarCell.attr("id"), "click");
            }
        <CFElse>
            CalendarEvents(myCalendarCell.attr("id"), "click");
        </CFIf>
    }
    alert("done!");


With this set of code:
        alert("done with first loop");
        myDiv = $(".CalendarWrapper");
        alert("done with second evaluation");
        
        $("table [EMAIL PROTECTED]")
                .filter(function() {
                        for (var i=0; i<dateValues.length; i++);
                                return (this.getAttribute('dateValue') == 
dateValues[i]);
                })
                .each(function() {
                        myCalendarCell = $(this);
                        myShiftDate = myCalendarCell.attr("dateValue");
                        myTempDate = $.odbcDateTimeParse(myShiftDate);
                        myBackgroundColor = "#ThisWeekdayColor#";
                if(!(myTempDate.getDay() % 6)){
                    myBackgroundColor = "#ThisWeekendColor#";
                }
                
myCalendarCell.removeClass("CalendarCellDisabled").addClass("CalendarCellEnabled").attr("state",
"Enabled").css({background:myBackgroundColor,
color:"#ThisFlexOrderEntryNormalTextColor#"});
                <CFIf ParameterExists(ThisSelectedDate)>
                    if("#ThisSelectedDate#" == myShiftDate){
                        CalendarEvents(myCalendarCell.attr("id"), "click");
                    }
                <CFElse>
                    CalendarEvents(myCalendarCell.attr("id"), "click");
                </CFIf>
                });
                
    alert("done!");


This should positively impact performance and you might be able to
pass in myDiv as the context for the selector like this:
$("table [EMAIL PROTECTED]", myDiv)

Of course this is all untested but should give you some direction on
how to implement the filter method.

--
Brandon Aaron

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

Reply via email to