Skip to content

Commit 4b3839d

Browse files
committed
Edited README.md via GitHub
1 parent efeb42b commit 4b3839d

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

README.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ The reason for the first two changes are that for some work flows it is likely o
5353
* * *
5454
**Note**
5555

56-
The intention is for that mixing the previous name-level properties with these newer selector wide attributes should work well.
56+
The intention is for that mixing the previous name-level properties with these newer selector wide attributes should work.
5757
For example, given the following code:
5858

5959
```javascript
@@ -67,7 +67,23 @@ $("input").link(model,
6767
});
6868
```
6969

70-
All inputs on the page would be linked to model through the multiplication converter except for an input with the a name (or failing that, id) attribute attribute equal to "filename", which would use the the toLowerCase() converter. However, this is not yet implemented because it conflicts with the idea that specifying specific attributes, like "filename" above, would cause only that mapping to actually be created.
70+
All inputs on the page would be linked to model through the multiplication converter except for an input with a name (or failing that, id) attribute equal to "filename", which would use the the toLowerCase converter. However, this is not yet implemented because it conflicts with the idea that specifying specific attributes, like "filename" above, would cause only that mapping to actually be created. Solutions:
71+
1. The presence of selector wide keywords on the mapping object would imply that all elements matching the selector are to be bound, and any specific attribute named mappings would simply take precedence.
72+
2. Specific attribute mappings would still imply that only those elements are to be mapped, and selector wide elements would simply provide additional functionality for those mappings. For example, you could specify a few attributes with name mappings, and have a selector wide __convert function that just applied to all those mappings:
73+
74+
```javascript
75+
var person = {};
76+
$("form").link(person, {
77+
firstName: {
78+
name:"first-name",
79+
twoWay:false
80+
},
81+
lastName: "last-name",
82+
__convert: function(value){return value.toUpperCase();}
83+
});
84+
```
85+
This would imply that firstName is mapped one way to person["first-name"], lastName is two-way mapped to person["last-name"], and both mappings go through the UpperCase convert function.
86+
4. Simply not allow mixing of the mapping styles.
7187

7288
## jQuery(..).link() API
7389

@@ -212,7 +228,8 @@ This example links the height of the element with id "rank" to the salesRank fie
212228

213229
**Selector-wide converter functions**
214230

215-
As stated in the introduction, it is possible to apply selector-wide convert and convertBack functions. By using the keywords __convert and __convertBack at the highest level of the mapping object, it will apply the functions for all elements matching the selector. For example:"
231+
As stated in the introduction, it is possible to apply selector-wide convert and convertBack functions. By using the keywords __convert and __convertBack at the highest level of the mapping object, it will apply the functions for all elements matching the selector. For example:
232+
216233
```html
217234
<form>
218235
<input name="inputa" type = "text"/>

0 commit comments

Comments
 (0)