Comments (3)
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.
For question №1 – there are several approaches to achieve this kind of behavior.
- 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. - 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. - 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.
I had guessed your answer ;-)
Thank you for your help
from jquery.my.
Related Issues (20)
- Styler corrupts @keyframes sections
- Cannot use Enter in textarea in nested form. HOT 2
- $.my.locale does not change default locale HOT 1
- 引入my.js报错 HOT 1
- isS is not a function HOT 1
- Internal radio events reach only first listener
- Modal issues HOT 1
- Data only updates once HOT 2
- Issue with browser autocomplete forms HOT 1
- Validation error message not working on custom validation function HOT 2
- isS is not a function HOT 5
- Awesome job !! HOT 1
- Support binding for inputs of type "tel" and "email" HOT 2
- List renderer drops rows, which hashes are like obj default methods ("constructor", "valueOf" etc)
- Detecting change in linked field HOT 2
- it could not run with sugar 2.0.4 HOT 2
- Identify which event caused the control to redraw/recalc (invoked bind function) HOT 2
- Nested form/list validation errors are not being cleared HOT 9
- does it support a grandson list form? HOT 2
- how to set a value HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery.my.