zoukankan      html  css  js  c++  java
  • How to use umbraco datetime property editor

    When I was using Umbraco datetime property editor, I met with a problem that the editor must be first time initialized with value, if I want to change the value later after the control is rendered, I have to use javascript.

    Below pasted the code.

    editor part:

     <umb-property property="ExpiryDate">
                            <umb-editor model="ExpiryDate"></umb-editor>
                        </umb-property>
    

    the controller initialization part:

    function buildDateTimePickerModel(alias, label, description, value) {
    	        return {
    	            editor: "Umbraco.DateTime",
    	            label: label,
    	            description: description,
    	            hideLabel: false,
    	            view: "datepicker",
    	            alias: alias,
    	            value: value,
    	            validation: {
    	                mandatory: false,
    	                pattern: ""
    	            },
    	            config: {
    	                dateFormat: "YYYY-MM-DD HH:mm:ss",
    	                pickDate: true,
    	                pickTime: true,
    	                useSeconds: true
    	            }
    	        };
    	    };
    $scope.ExpiryDate = buildDateTimePickerModel('ExpiryDate', 'ExpiryDate', 'Enter the ExpiryDate', null);
    

      so, this code will guarantee that at least you can see the control as soon as it is loaded, but, you can see, what if I have a asynchonous model that I need to apply to this control later? my current solution is to find the control by its id, and then apply value to it with formatters, all these stuffs are actually wrapped in an angular js controller, so, the setter method of the control would be:

    $('#ExpiryDate').val($filter('date')($scope.CouponCode.ExpiryDate, 'yyyy-MM-dd hh:mm:ss'));
    

      anywhere!

  • 相关阅读:
    Selenium RC和WebDriver的实现区别(一)
    布线问题
    C语言播放音乐
    圈水池
    双向BFS
    Asp.net MVC3 Razor中的扩展HtmlHelper的返回类型问题
    使用Visual Studio 利用WinGDB编译和远程调试嵌入式Linux的程序
    IoTSharp部署教程Sqlite分表篇
    sql 2005性能调优
    Sql养成一个好习惯是一笔财富
  • 原文地址:https://www.cnblogs.com/hualiu0/p/6144308.html
Copyright © 2011-2022 走看看