Giter Site home page Giter Site logo

Comments (6)

jonsamwell avatar jonsamwell commented on August 17, 2024

Hi!

Thanks for using the module. Yeah you are correct the html is not being recompiled so the directive is not initializing. You will need to do something like this:

makeInvalid = function (el, errorMsg) {
     el.addClass('redtext')
     el.attr("tooltip", "Tooltip here!");  
     $compile(el.contents())(el.scope());
}

You might need to check the scope and make sure the element is not using an isolatedScope.

You could also have a look at http://stackoverflow.com/a/21487754/1162133

Jon

from angular-auto-validate.

cozyazure avatar cozyazure commented on August 17, 2024

Hi Jon

Still not working, I guess I must have missed out something. I tried to look into el.scope(), I wonder if it is returning the same scope back to the directive.

Here is a <a href=http://plnkr.co/edit/Wzn5GK7XG99PRFlAjUIJ?p=preview">plunkr that illustrates the situation. As you can see, in both input fields their validation requirements are the same. And yes their text do turn red on invalid state, but the tooltip was appended but not $apply()ed. :(

Anyway, this module is definitely awesome. :D

from angular-auto-validate.

jonsamwell avatar jonsamwell commented on August 17, 2024

Thanks! I'll take a look tonight :-)

from angular-auto-validate.

jonsamwell avatar jonsamwell commented on August 17, 2024

This works for me but the model is removed for some reason? I'll have a better look later.

makeInvalid = function(el, errorMsg) {
        el.addClass('redtext');
        el.attr("tooltip", "This is tooltip!");
        var scope = el.scope();
        $compile(el)(scope);
      }

from angular-auto-validate.

cozyazure avatar cozyazure commented on August 17, 2024

The model is removed because every time the input is invalid, it will invoke our makeInvalid function, and hence it will force a $compile, thus flushing(refreshing) the ng-model away. Lol. Very tricky. I will try to solve this or find any workaround.

If it is resolved I would love to have a PR and make some contribution or so.

from angular-auto-validate.

jonsamwell avatar jonsamwell commented on August 17, 2024

Try this....

makeInvalid = function(el, errorMsg) {
        var val = el.val(),
            scope = el.scope();
        el.addClass('redtext');
        el.attr("tooltip", "This is tooltip!");
        $compile(el)(scope);
        $timeout(function () {
          el.val(val);
        });
      }

A pull request would be awesome! :-)

Jon

from angular-auto-validate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.