angular-xeditable icon indicating copy to clipboard operation
angular-xeditable copied to clipboard

ng-form support

Open ctwoodwa opened this issue 10 years ago • 2 comments

Any chance you could support ng-form directive instead of requriing the form tag?

ctwoodwa avatar Oct 02 '15 19:10 ctwoodwa

+1

I've done some code changes to support it on my installation:

  1. add '?^ng-form' to the 'require' option in editableDirectiveFactory: require: [overwrites.directiveName, '?^form', '?^ng-form'],

  2. reverse the order of how the directive finds out whether a form exists or not: if e-form is specified, it takes precedence over a parent form/ng-form. Once e-form is found, we lookup either a form or ng-form with the same name in the doc:

    // element explicitly references e-form - take precedence:
    if(attrs.eForm) { // element not wrapped by <form>, but we hane `e-form` attr
      var getter = $parse(attrs.eForm)(scope);
      if(getter) { // form exists in scope (above), e.g. editable column
        eFormCtrl = getter;
        hasForm = true;
      } else { // form exists below or not exist at all: check document.forms
        for(var i=0; i<$document[0].forms.length;i++){
          if($document[0].forms[i].name === attrs.eForm) {
            // form is below and not processed yet
            eFormCtrl = null;
            hasForm = true;
            break;
          }
        }
        var ngforms = $('ng-form[name="' + attrs.eForm + '"]');
        if (ngforms.length > 0) {
            eFormCtrl = null;
            hasForm = true;
        }
      }
    } else if(ctrl[1] || ctrl[2]) {
        // element does not explicitly reference e-form but already wrapped by form
        eFormCtrl = ctrl[1] || ctrl[2];
        hasForm = true;
    }
    

see if this helps... note I'm using Jquery here... guess I can use angular's liteJQ instead and iterate ng-forms manually instead of using a selector..

sagimann avatar Nov 26 '15 10:11 sagimann

@sagimann Can you post how you were using the ng-form? I'm trying to use the code above but I don't think I using the editable with ng-form correctly. I'm not able to submit the form.

ckosloski avatar Mar 03 '17 14:03 ckosloski