tags:

views:

38

answers:

3

Here's the code:
This function call 'displayRmuForm' after the dates are calculated from effectivedate. IT'S NOT WORKING :(

var displayRmuForm = function() {
    var txtEffectiveDate= $get('ctl00_ContentPlaceHolder1_DetailsView1_txtEffectiveDate');

    if (!rmuVisible && txtEffectiveDate.value.length > 0 ) {
        $(".container").show(250);

    } else { 
        $(".container").hide(250); 
    }
    rmuVisible = !rmuVisible;
}


var effectiveDate_blur = function(e) {
    var effectiveDate = null;
    if (this.value.length > 0) {
        effectiveDate = new Date(eval('"' + this.value + '"'));
        setRmuDates(effectiveDate);
        displayRmuForm();
    }
}
A: 

Try using e.target instead of this.

Much safer: call the event handler passing the value of 'this' as another parameter.


(disclaimer: I'm not a JS developer)

Vlagged
tried e.target and still not calling the 'displayRMUForm'.
Kombucha
cf. [quirksmode.org](http://www.quirksmode.org/js/events_properties.html#target), there are much more checks to be done for a dom event. This is why i recommended passing this as function parameter e.g. `onclick='effectiveDate_blur (this)'` and then you have the `.value.length` corectly based.You can always insert a [debugger](http://msdn.microsoft.com/en-us/library/0bwt76sk(VS.85).aspx) statement for stepping into that code to see what's wrong
Vlagged
A: 

Try forcing rmuVisible to be false in your blur handler like this... I am thinking the function is firing but the conditions aren't being met to display your form.

var effectiveDate_blur = function(e) { var effectiveDate = null; if (this.value.length > 0) { effectiveDate = new Date(eval('"' + this.value + '"')); setRmuDates(effectiveDate); rmuVisible = false; displayRmuForm(); } }

Hcabnettek
It's improving but I still need to do EXTRA CLICK on the page to show dates on 'displayRMUForm'. Is there any way I don't have to do extra click?Thanks for the input. :)
Kombucha
How about disabling you're rmu checkbox until the user enters a value in your effective date field? You could then fire the check() or click() event on your checkbox and popup your form. They wouldn't have to click the checkbox at all.That would only work tho if 'rmu' is implied when you pick an EffectiveDate. We have no way of knowing the business rules of your app tho without any requirements.Maybe just disable your checkbox and then just enable it in the effectiveDate_blur function. Allow the user to click it and popup your form.Hope this helps.
Hcabnettek
A: 

Is it calling your blur handler at all? (either debug or put an alert or something)

You haven't shown us how you wired up the function to the event, so it could be as simple as that the browser doesn't even know to call the effectiveDate_blur() function.

GalacticCowboy