Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how does the converter work #188

Open
cooolbasha opened this issue Jul 7, 2014 · 6 comments
Open

how does the converter work #188

cooolbasha opened this issue Jul 7, 2014 · 6 comments

Comments

@cooolbasha
Copy link

Based on the radio button I wanted to show another field. so I used the converter to bind radio button + selector for the text with the converter. So when the radio button is clicked on, the converter function would call and it will be either hide or show based on the val passed(on/off).
there are couple of issues

  1. the converter expects me to pass value back...which I am managing by passing model.get(text field)
  2. when I am setting some value to the text field(from the view). the converter is called..I was thinking the converter will be called only when there are change in the radio button because the binding[radiobutton] = [ {selector:[radiobutton]}, {converter:function(){},selector:[textbox]}. the binding is based on the radio button .some change to the radio button should trigger it..But here the change to text box is calling the converter function.

why cannot the converter have and option to quit processing based on the return values..as in this case the main intention is to just get the text field displayed.
and why trigger when the other field values change...

@cooolbasha
Copy link
Author

I am using the el attribute class to set/unset the show / hide..but I still feel that there should be ability to quit the converter when required./ there should be a option to have 1 field deciding the converter value..

@cooolbasha
Copy link
Author

For age -> year conversion the converter is getting triggered 7 times ..when I set an value in the view

Bindings in Coffee Script
                @bindings.yob = [@bindings.yob].add
                        selector: "[name=age]"
                        converter: (direction,val,attr,model,selector)->
                            console.log 'arguments',arguments
                            return wed.CYEAR - val   #current year - year selected

Debugger/Console - when I changed the Yob to 1991

arguments ["ModelToView", "1991", "yob", User, Array[1]]
arguments ["ViewToModel", "23", "yob", User, Array[1]]
arguments ["ModelToView", 1991, "yob", User, Array[1]]
arguments ["ViewToModel", "23", "yob", User, Array[1]]
arguments ["ModelToView", 1991, "yob", User, Array[1]]
arguments ["ModelToView", 1991, "yob", User, Array[1]]
arguments ["ModelToView", "1991", "yob", User, Array[1]]

and the array is
 Array[1]  
   0: select#age.wed-init
   length: 1

It seems like it is working...But I don't know..how..

@cooolbasha
Copy link
Author

is this repo active?

@theironcook
Copy link
Owner

Yes.it is active but I am not near a computer for another week...

@cooolbasha
Copy link
Author

any updates

@platinumazure
Copy link
Contributor

Hi @cooolbasha, could you please put your example in a JSFiddle or similar? I want to look into this but it's really hard to follow exactly what you're trying to do. It's definitely possible to show/hide fields based on other model values, but I don't know what you're trying to do and what you're doing so I won't be a lot of help just yet. Please ping me back when you have the code in a JSFiddle and I'll take a look! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants