locked
Using html5 input search type in lightswitch html RRS feed

  • Question

  • Hi Everyone

    I want to use the new html5 input search type for a search box in my lightswitch html application so what i did is in the postRender method for a text box i added this:

    searchInput = $(element).children("input:first");   

    searchInput.attr({       

    placeholder: "Search",       

    type: "search",   

    });


    and it works but now the search dose not work any more so how can i add an event listener when the value changes in the input field?

    In plain JavaScript it would be

    var s = document.getElementById("search");
    s.addEventListener("search", function(e) {
        ...
    }, false);

    But in lightswitch i can not find element by id so how can i do that?

    (there is no jquery alternative for that as i know).

    Thanks

    Wednesday, January 28, 2015 2:13 AM

All replies

  • and it works but now the search dose not work any more so how can i add an event listener when the value changes in the input field?

    In plain JavaScript it would be

    var s = document.getElementById("search");
    s.addEventListener("search", function(e) {
        ...
    }, false);

    For the usage of addEventListener, Huy shares her experience on this.

    If you're using addChangeListener / addEventListener in your code, objects on HTML Client have different lifetime. Entity Objects tend to stay around much longer than Screen Objects. So if you add event listeners to an Entity Object on a Screen, when that Screen is closed, the listeners are still active and you need to clean up that listener.

    Hope it helps.

    Best regards,

    Angie


    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.

    Thursday, February 19, 2015 6:39 AM