[CLOSED] Panel.Update returns NaN in IE + FF, working fine in Chrome

  1. #1

    [CLOSED] Panel.Update returns NaN in IE + FF, working fine in Chrome

    Hello,

    I have a Panel where I display a total and relative time, dependent upon a slider value.

    myPanel.update(Ext.String.format('<b>{0}</b><br><b>- - -</b><br><b>{1}</b>',
    removeYMD(value1),value2));
    The Chrome Result looks like:

    11:19:33
    - - -
    00:04:01
    IE and Firefox:

    NaN:NaN:NaN
    - - -
    aN:aN:aN
    for example, my function removeYMD gets a Date object and returns a string:

    function removeYMD(myDate) {
    var myTime= myDate.getHours() + ":" + twoDigits(myDate.getMinutes()) + ":" + twoDigits(myDate.getSeconds());
    return myTime;
    }
    In my first research I have read something about that FF has problems with parsing Numbers inside a bold tag? Sounds odd to me. Any Idea how to fix that?
    Last edited by Daniil; Nov 05, 2012 at 4:11 PM. Reason: [CLOSED]
  2. #2
    Can you post your twoDigits function.

    It's always best if you can provide a simplified .aspx code sample demonstrating the whole scenario. If we can copy/paste your sample directly into our test project without having to piece together a bunch of code snippets, you will get a faster response.
    Geoffrey McGill
    Founder
  3. #3
    As well, you shouldn't require a separate function to format those Date object values. You can use the Ext.Date helpers, see

    http://docs.sencha.com/ext-js/4-1/#!/api/Ext.Date

    Example

    Ext.Date.format(value1, 'G:i:s');
    Hope this helps.
    Geoffrey McGill
    Founder
  4. #4
    Hi Geoffrey,

    this is my two digits function:

    
    function twoDigits(value) {
        var tempString = new String(value);
        if (tempString.length < 2) {
            tempString = "0" + tempString;
        }
        return tempString;
    }
    I will have a look at these date helpers and report if this solved the problem.
  5. #5
  6. #6
    I think you'll have to post a simplified .aspx code sample demonstrating how to reproduce the whole scenario. Please ensure you remove all code that is not directly related to reproducing the problem.
    Geoffrey McGill
    Founder
  7. #7
    Ok I have now found and solved the problem. I'm getting my date object with a webrequest, the result is serialized with newtonsoftJSON. In my previous code I returned it as a String and created a new date object in Javascript.
    The problem is that FF and IE only accept specific constructors for a JS date object whereas chrome seems to be more flexible. You can read more about it here: http://biostall.com/javascript-new-d...date-in-safari

    I have changed

    TimestampUTC.Value.ToString("yyyy-MM-dd HH:mm:ss")
    to

    TimestampUTC.Value
    and instead of serializing a string, I'm serializing a .net Date object.

    Thanks anyway for the hint with the ext date helper, this makes things easier.

    Can be closed
  8. #8
    Thank you for sharing a solution.

    It is good to know and can help someone on the forums in the future.

Similar Threads

  1. Replies: 4
    Last Post: Jul 25, 2012, 5:45 AM
  2. [CLOSED] How to show mask on ajax update panel update
    By egvt in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 18, 2012, 9:36 PM
  3. Replies: 5
    Last Post: Jun 10, 2011, 6:35 PM
  4. [CLOSED] Update ASP Update Panel with Direct Event
    By sharif in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 24, 2010, 12:48 AM
  5. Replies: 3
    Last Post: Sep 13, 2008, 10:09 AM

Posting Permissions