Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Colin Wiseman 47 posts 178 karma points
    Jun 08, 2020 @ 11:18
    Colin Wiseman
    0

    umb-editor datepicker not always displaying the correct date

    Hello,

    I have a custom editor with a datetime picker on it:

    <umb-editor model="startDatePicker"></umb-editor>
    

    with an angular controller turning it into a datepicker thus:

    $scope.entry = {
                StartDate: moment().format(),
                EndDate: moment().add(7, 'days').format()
            };
    
    $scope.startDatePicker = {
                view: 'datepicker',
                value: $scope.entry.StartDate,
                validation: {
                    mandatory: true,
                    pattern: ""
                },
                config: {
                    pickDate: true,
                    pickTime: false
                }
            };
    

    When my form reloads using values from the database I set the value of the startDatePicker like:

    $scope.startDatePicker.value = moment($scope.entry.StartDate);
    

    And this works...sometimes. Sometimes the value that is displayed is the initial value of today's date, and sometimes it is the correct value.

    And interestingly when I go to resave the form without changing the values retrieved from the database:

    entry.StartDate = $scope.startDatePicker.value
    

    is the correct value that I want, albeit what the datepicker is display is the wrong value.

    What am I doing wrong that sometimes it displays the correct value and sometimes doesn't?

    Help!

  • Colin Wiseman 47 posts 178 karma points
    Jun 08, 2020 @ 14:23
    Colin Wiseman
    100

    My solution I found was here:

    https://www.enkelmedia.se/blogg/2013/12/4/umbraco-use-the-rich-text-editor-tinymce-in-a-custom-section/

    I wrapped all the umbraco directives in a "lazy load" idea as presented in the page linked. This to me seems a bit heavy handed for all umb-editor directives on page which if you have a few datepickers, rtes and media pickers (like my page) then it gets quite "array" heavy. I would prefer just to load the directives after the data has arrived.

    Is there a better way? e.g. do controllers have constructors that can pull data before the rest of the page loads?

Please Sign in or register to post replies

Write your reply to:

Draft