Giter Site home page Giter Site logo

Comments (3)

ermouth avatar ermouth commented on July 24, 2024

Thanks for your question, Camel. I think I need to update reference to accent how this works inside $.my functions.

$.my apps intended to be more or less self-contained – to build systems were every app is a single json doc without (or with minimal set) of external dependencies. To ensure consistent runtime environment for every manifest fn, each init, bind, check, css, style and manifest function of given manifest receives manifest itself as this object.

Out-of-syntax user functions, defined at a first level of given manifest tree, also are bound to the manifest via this when app starts.

So nearly any fn called inside manifest is bound to manifest itself – you may think about manifest as if it‘s a sort of class definition.

To fix you particular case you can write this.validator.checkNotEmpty.bind(this) in the manifest – it binds function to this explicitly. I think it can help.

Thanks again for you deep-level question!

from jquery.my.

ermouth avatar ermouth commented on July 24, 2024

For question №1 – there are several approaches to achieve this kind of behavior.

  1. You can explicitly define a set of events $.my listens for the control. For example events:"blur.my" set for <textarea> ensures that validator fires after field left focus. It sometimes means that user finished with this field.
  2. You can do it right in the way you do it now – but keeping allowEmptyField as property of manifest instance. So you check function is able to set/retrieve its value from this.allowEmptyField during runtime.
  3. You can use regexps like /^(|\d{3,5})$/ – it allows 3-5 digits, but stays dumb if string is empty. In this case you can make additional proxy <div> that watches all your fields (watch:"#f1,#f2,f3") and tells user something like ‘You must write something in fields F1, F2, F3’.

from jquery.my.

camelaissani avatar camelaissani commented on July 24, 2024

I had guessed your answer ;-)
Thank you for your help

from jquery.my.

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.