GithubHelp home page GithubHelp logo

Comments (3)

g8anusha avatar g8anusha commented on June 3, 2024

Sorry, some issue with the twiddle. Twiddle not saving my code. Please find the template code.

{{#validated-form
	model=(changeset model UserValidations)
  on-submit    = (action "submit")
  submit-label = 'Save' as |f|}}

  {{f.input label="First name" name="firstName"}}
  {{#f.input label="Last name" name="lastName" as |fi|}}
    {{textarea name="lastName" onupdate=fi.update onhover=fi.setDirty
  {{/f.input}}
  {{f.submit label="Save" disabled=f.model.isInvalid}}

{{/validated-form}}

from ember-validated-form.

czosel avatar czosel commented on June 3, 2024

Hi @g8anusha,

the key to achieving this behaviour is calling fi.setDirty when your component goes out of focus. Getting this right can sometimes be tricky because how the event is triggered depends on the component you're using: onhover is for example just used in our demo app and won't work with textareas. When you're using the ember {{textarea}} you'll have to use input and focusout (see ember docs), with a native <textarea> it would be oninput and onblur.

I created a twiddle with a working demo.

So, to summarize: It really depends on what kind of custom component you're using. Textareas might not be a perfect example since we support them out of the box anyway. For debugging purposes, I'd recomment to bind you event listener to a custom action to see if it actually gets fired before changing it to call fi.update or fi.setDirty.

Hope that helps!

PS: My current workflow with ember twiddle is to name the twiddle, then hit File > save to GitHub Gist, and finally open the current page in a new Tab to see if everything actually has been saved.

from ember-validated-form.

g8anusha avatar g8anusha commented on June 3, 2024

Worked like magic! Thanks a lot! 💯

from ember-validated-form.

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.