2

我有两个控件一个是设置另一个不是。任何可以提供帮助的 jQuery 大师都会很棒。我将添加所有代码调用:

  1. return {
    init: function (ctrl_IDs) {
        _benefitPlans.pop();
        _categories.pop();
        _definitions.pop();
        _diagGroups.pop();
        _ageGroups.pop();
        _placeOfServices.pop();
        _serviceID = getServiceID();
    
        if (ctrl_IDs) {
            _ids = ctrl_IDs;
        }
    
        initialHideEditPanels();
        initialButtonDisable();
    
        bindDatePickerEvents();
        bindButtonEvents();
        bindInputBlurEvents();
        bindCheckboxEvents();
        bindRadGridEvents();
    
        initialDataBind();
    
        toggleServiceCodeInputEnabled(false);
        toggleBenefitPlanInputEnabled(false);
       }
     }
    }(jQuery, $telerik));  
    

我们需要看看 bindDatePickerEvents();

 function bindDatePickerEvents() {
    bindDates($find(_ids.txtServiceCodeEffectiveDate), $find(_ids.txtServiceCodeEndDate));
    bindDates($find(_ids.txtBenefitPlanEffectiveDate), $find(_ids.txtBenefitPlanEndDate), _attrTypes.benefitPlan);//TODO RBD SW#6848
    bindDates($find(_ids.txtServiceCategoryEffectiveDate), $find(_ids.txtServiceCategoryEndDate), _attrTypes.serviceCategory);
    bindDates($find(_ids.txtServiceDefinitionEffectiveDate), $find(_ids.txtServiceDefinitionEndDate), _attrTypes.serviceDefinition);
    bindDates($find(_ids.txtDiagnosisGroupEffectiveDate), $find(_ids.txtDiagnosisGroupEndDate), _attrTypes.diagnosisGroup);
    bindDates($find(_ids.txtAgeGroupEffectiveDate), $find(_ids.txtAgeGroupEndDate), _attrTypes.ageGroup);
    bindDates($find(_ids.txtPlacesOfServiceEffectiveDate), $find(_ids.txtPlacesOfServiceEndDate), _attrTypes.placeOfService);
}

下一个 bindDates()

    function bindDates(effDate, endDate, attrType) {
    //Declare variables to be used in the JavaScript Function
    var effDateID = effDate.get_id();
    var endDateID = endDate.get_id();
    var tmp = attrType;

    $(effDate.get_element()).on('validDateEntered', { effID: effDateID, endID: endDateID, type: tmp }, function (evt) {
        setEffectiveDates($find(evt.data.effID), $find(evt.data.endID), evt.data.type);
    });

     effDate.add_dateSelected(function (sender, args) {
        validateDatesRange(effDate, endDate);
    });

    effDate.get_dateInput().add_blur(function (sender, args) {
        validateDatesRange(effDate, endDate);
    });

    endDate.add_dateSelected(function (sender, args) {
        validateDatesRange(effDate, endDate);
    });

    endDate.get_dateInput().add_blur(function (sender, args) {
        validateDatesRange(effDate, endDate);
    });
}

设置生效日期

    function setEffectiveDates(effDateCtrl, endDateCtrl, attrType) {
    var type = attrType !== undefined ? attrType : -1,
        effDate = effDateCtrl.get_selectedDate(),
        endDate = endDateCtrl.get_selectedDate(), 
        effDateString = effDate == undefined ? '' : dateToString(effDate),
        endDateString = endDate == undefined ? '' : dateToString(endDate);

    switch (type) {
        //RBD CODING ON SATURDAY MORNING CARTOONS
        case _attrTypes.benefitPlan:
            _selected.benefitPlan.eff_date = effDateString;
            _selected.benefitPlan.end_date = endDateString; 
            break;
        case _attrTypes.serviceCategory:
            _selected.serviceCategory.eff_date = effDateString;
            _selected.serviceCategory.end_date = endDateString;
            break;
        case _attrTypes.serviceDefinition:
            _selected.serviceDefinition.eff_date = effDateString;
            _selected.serviceDefinition.end_date = endDateString;
            break;
        case _attrTypes.diagnosisGroup:
            _selected.diagnosisGroup.eff_date = effDateString;
            _selected.diagnosisGroup.end_date = endDateString;
            break;
        case _attrTypes.ageGroup:
            _selected.ageGroup.eff_date = effDateString;
            _selected.ageGroup.end_date = endDateString;
            break;
        case _attrTypes.placeOfService:
            _selected.placeOfService.eff_date = effDateString;
            _selected.placeOfService.end_date = endDateString;
            break;
        default:
            _details.eff_date = effDateString;
            _details.end_date = endDateString;
            break;
    }
}

完成 validateDatesRange

function validateDatesRange(effDateCtrl, endDateCtrl) {
    var result = true,
        effDate = effDateCtrl.get_selectedDate(),
        endDate = endDateCtrl.get_selectedDate(),
        cell = $(effDateCtrl.get_element()).parents('td').first();

    if (effDate && endDate) {
        if (effDate > endDate) {
            var div = "<div class='errorMessage' style='display:none;'>Effective date must be less than end date.</div>";
            $(div).prependTo(cell).fadeIn();
            result = false;
        }
    }

    if (result) {
        cell.find('div.errorMessage').fadeOut(200, null, function () {     $(this).remove(); });
        $(effDateCtrl.get_element()).trigger('validDateEntered');            
    }
    return result;
}

同样,这里的问题是 endDateCtrl 没有更改日期。当页面打开时,数据被填充到网格中,最终用户单击编辑按钮,这会填充一个面板。但是,effDateCtrl 显示正确的日期,但 endDateCtrl 不显示,但是如果您单击编辑按钮两次,则会填充日期。我难住了。

    function pageLoad() {
        $(document).ready(function () {
            sc.init(getClientIDs());
        });
    }
4

0 回答 0