locked
How To convert Html Element QueryCollection (winjs.utitlies.querycollection)

    Question

  • I have a DIV like this

    <div id="debug">Debug</div>

    I have an event handler for click event like this

    WinJS.Utilities.query('#debug').listen('click',

    function () {           

    WinJS.Utilities.addClass(this, 'red');       

    });

    Inside the handler this refers to HTMLElement while i want to be converted to queryCollection so that i can do something like this

    this.addClass('red'); //'addClass' is method of query collection



    • Edited by rusinova Tuesday, December 4, 2012 3:26 PM
    Tuesday, December 4, 2012 3:14 PM

Answers

  • var queryColl = new WinJS.Utilities.QueryCollection(this);
    queryColl.addClass('red');


    • Marked as answer by rusinova Wednesday, December 5, 2012 7:55 PM
    Tuesday, December 4, 2012 8:02 PM

All replies

  • var queryColl = new WinJS.Utilities.QueryCollection(this);
    queryColl.addClass('red');


    • Marked as answer by rusinova Wednesday, December 5, 2012 7:55 PM
    Tuesday, December 4, 2012 8:02 PM
  • thanks, i missed the keyword 'new'
    Wednesday, December 5, 2012 7:55 PM