4

Here is my code

<span editable-select="item.text" e-ng-options="p.id as p.name for p in products" e-form="rowform" 
          onbeforesave="checkName($data)" e-required e-name="name" 
          e-onChange="scopeFunction($data)">
      {{ showProductName(item.text) || 'Enter Name of a product' }}
    </span>

Is it possible to access controller's $scope in e-onChange?

If I enter e-onChange="scopeFunction(data)" it throws an error "ReferenceError: scopeFunction not defined"

What I want is after selecting a new value to be able to change another field's value.

5
  • I wanted to also add that I want the change event to fire before I save the value. Commented May 11, 2015 at 1:22
  • 1
    cannot use onaftersave instead of e-onChange? Commented May 11, 2015 at 1:47
  • can you show your controller's code? Commented May 11, 2015 at 7:42
  • Hey, I think I managed to do it via onaftersave. I decided to just leave it. Onaftersave doesn't exactly do what I wanted because I wanted another cell's value to change when a user enters some value in the selected editable cell input (before I click "save" changes). Commented May 18, 2015 at 12:11
  • yes, I have the same problem. i need to change a 2nd cell based on a first cell's change. Xeditable doesn't seem to let you do that during edit mode. Commented Jul 20, 2015 at 20:09

2 Answers 2

12

Use angular's e-ng-change instead (with the 'e-'-prefix for the editable element):

<span editable-select="item.text" 
    e-ng-options="p.id as p.name for p in products" e-form="rowform" 
    onbeforesave="checkName($data)" e-required e-name="name" 
    e-ng-change="scopeFunction($data)">
        {{ showProductName(item.text) || 'Enter Name of a product' }}
</span>
Sign up to request clarification or add additional context in comments.

Comments

0

Use e-ng-change="onChange(field)" with e-ng-model-options="{allowInvalid:true}" to trigger onChange events

                   <input 
                      type="text" ng-model="newEntity[field.name]"
                      name="{{field.name}}" placeholder="{{field.placeholder}}"
                      value="{{field.defaultValue}}"
                      e-ng-change="onChange(field)"
                      e-ng-model-options="{allowInvalid:true}"
                   />

Note: e-ng-model-options will help tracking onChange events even if ng-pattern is $invalid. See More: Angular.js - ng-change not firing when ng-pattern is $invalid

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.