Search code examples
angularjsangular-directivex-editable

Customizing & Styling Angular X-Editable Popover Input


I'm using angular x-editable in my project for an editable popover. I've successfully made changes to the look of my confirmation button to an .svg I wanted to use and removed the Cancel button doing:

app.run(function(editableOptions, editableThemes) {
  editableOptions.theme = 'default';
  editableThemes[default].cancelTpl = '';
  editableThemes[default].submitTpl = '<img class="popoverSubmitBtn" 
    src="images/confirmationBtn.svg" ng-click="$form.$submit()">';
});

However I am having issues when trying to change editableThemes[default].inputTpl. It seems like changes to inputTpl are not being registered for some reason. What I would like is for the input box that shows in the popover to have a circular 'x' button to clear the current input WITHIN the input text field.

This was actually default behavior in the original x-editable (see here at Twitter typeahead.js demo). While there is an equivalent to use editableOptions.displayClearButton=true, this creates an entire button next to the input box, much like the confirmation button, which is not what I want.

My plan was to use a directive here that provides the 'clear' button and use editableThemes[default].inputTpl = '<input type="text" reset-directive>'; but again, seems like its broken. Even this open issue here leads me to believe it was never working as intended.

Has anyone had any luck with this or knows of any workarounds that may help in my situation?

ALSO- a bit unrelated but on the topic of styling, how do I move the position of where the popover shows up? Currently it's smack-dab in the middle of where my cursor is when I click the text to activate popover, but I would like it a bit higher and to the right.


Solution

  • Got it working. For those with similar issues:

    • Styling for the popover can be controlled through xeditable.css found in the bower_components directory after installation
    • While inputTpl isn't functioning the way I expected, I added the custom directive to the input field using e-* (i.e. e-my-directive) with no issues.