locked
WinJS binding data-attr and using converter

    Question

  • I wont to bind to data-url
    I can do this by uing

    this['data-url']: ProductId WinJS.Binding.setAttribute
    

    But I also want to use my own converter, can I use 2 converters? how to do this, thanks

    this['data-url']: ProductId WinJS.Binding.setAttribute MyCoverters.MyConverter


    Alan Mosley - ThatsIT Solutions

    Tuesday, April 21, 2015 1:12 PM

All replies

  • Hi Alan,

    What is your purpose for using two converters?

    Not quite sure if we can do this, but I just wondering why you need two converters, you want to convert original data to temproy one and convert again to the final data? If so you can do something like this:

    ...
    <span id="loginName" 
        data-win-bind="innerText: name; style.color: userType LoginData.userTypeToColor">
    </span>
    ...
    
    WinJS.Binding.processAll(document.getElementById("loginDisplay"), LoginData.login);
    
    WinJS.Namespace.define("LoginData", {
            //Data Object
            login : { name: "myname", id: "12345678", userType: "admin" },
    
            //Converter function
            userTypeToColor: WinJS.Binding.converter(function (type) {
                //inner converter function. 
            })
        });
    
    

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 22, 2015 2:54 AM
    Moderator
  • I want to use a converter on a data-url attribute. But I need to use the built in converter WinJS.Binding.setAttribute first because of the “-“ data- attribute.
    Thanks


    Alan Mosley - ThatsIT Solutions

    Wednesday, April 22, 2015 5:38 AM
  • How about use a temporary hidden control for instance <input> but with hidden visibility as a middle layer?

    --James


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, April 27, 2015 1:34 PM
    Moderator