             @$('.range-from').datepicker({'autoclose': true})
             @$('.range-to').datepicker({'autoclose': true})
 
+            operator = @context.get('operator')
+            value = @context.get('value')
+          
+            if operator == '-range'
+                @inOutSelect.setSelection("not_between")
+            else
+                @inOutSelect.setSelection("between")
+
+            switch operator
+                when 'range', '-range'
+                    if value[0]?
+                        @$('.range-from').data('datepicker').setDate(
+                            new Date(value[0]))
+                    else
+                        @$('.range-from').val('')
+                    if value[1]?
+                        @$('.range-to').data('datepicker').setDate(
+                            new Date(value[1]))
+                    else
+                        @$('.range-to').val('')
+                when 'gte'
+                    @$('.range-from').data('datepicker').setDate(
+                        new Date(value))
+                when 'lte'
+                    @$('.range-to').data('datepicker').setDate(
+                        new Date(value))
         toggleHelpText: (event) ->
             @$('.help-block').toggle()
             event.preventDefault()

             
            return value

        setOperator: (operator) ->
            @operator = operator

            if operator == '-range'
                @inOutSelect.setSelection("not_between")
            else
                @inOutSelect.setSelection("between")

        setValue: (value) ->
            switch @operator
                when 'range', '-range'
                    if value[0]?
                        @$('.range-from').data('datepicker').setDate(
                            new Date(value[0]))
                    else
                        @$('.range-from').val('')
                    if value[1]?
                        @$('.range-to').data('datepicker').setDate(
                            new Date(value[1]))
                    else
                        @$('.range-to').val('')
                when 'gte'
                    @$('.range-from').data('datepicker').setDate(
                        new Date(value))
                when 'lte'
                    @$('.range-to').data('datepicker').setDate(
                        new Date(value))

    {DateControl}

            'click .range-help-button': 'toggleHelpText'

        initialize: (options) ->
            super(options)
            @model = options.model

        ui:
