vitalets / angular-xeditable

Edit in place for AngularJS
http://vitalets.github.io/angular-xeditable
MIT License
1.91k stars 404 forks source link

editable-bsdate doesn't seem to work with ui.bootstrap.popover (ui-popover-wrapper) #738

Closed osvathrobi closed 5 years ago

osvathrobi commented 6 years ago

My other controls are working fine within the popover except the date picker. Only the Submit and Cancel buttons appear in the popover.

<div class="ui-popover-wrapper">
  <a href="#" 
       editable-bsdate="startDate" 
       e-name="startdate" 
       e-single 
       e-show-calendar-button="false" 
       e-datepicker-popup="dd.MM.yyyy" 
       e-style="width:auto" 
       e-datepicker-mode="day" 
       e-is-open="true"
       uib-popover-template="'popover.html'"
       popover-is-open="popoverIsOpen"
       popover-append-to-body="true"
       onshow="popoverIsOpen = !popoverIsOpen" 
       onhide="popoverIsOpen = !popoverIsOpen"
       popover="true"
       popover-placement="top"
       popover-title="When should the first payment start"
       onaftersave="myform.$setDirty(true)">Event will start on {{startDate}}</a>
</div>

This seems to be the same reason why form-control class isn't added to inputs within a ui-popover. $templateCache.put('popover.html', self.editorEl[0].outerHTML) is used in the code to pass it over to the popover but the control hasn't finished being creating yet. (hacking in a setTimeout for this assignment fixes the issue, so I can confirm it is related to this)

osvathrobi commented 6 years ago

One hack-fix is to move this code from the self.render method into the self.show method right before triggering self.onshow:

if (self.popover) {
        var wrapper = angular.element('<div></div>');
        wrapper.append(self.editorEl);
        self.editorEl = wrapper;
        $templateCache.put('popover.html', self.editorEl[0].outerHTML);
}

This will fix both the missing class names and creating the bsdate controls.

ckosloski commented 5 years ago

@osvathrobi what do you mean by "hack-fix". Do you think this should be fixed in a different way that what you posted?

osvathrobi commented 5 years ago

@ckosloski I use this in production for over a year and it seems to be working fine. I meant "hack-fix" as in - it is not an official response from the contributors.