Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Start simple app using Module Pattern

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #165090
    Kuzyo
    Participant

    Hi guys.

    Here I find interesting article about module pattern on JS https://css-tricks.com/how-do-you-structure-javascript-the-module-pattern-edition/

    and started to write simple app – for creating TODO lists. But, from the start found problem(I think it something simple, but I can’t get);

    Here is my pen http://codepen.io/Kuzyo/pen/paoKi

    Can somebody explaine to me, why my getTask function doesn’t work in this way:

    getTask: function() {
               var self = this;
               s.textField.on("keydown", function(e) {
                  if(e.keyCode == 13) {
                    s.task = $(this).val();
                    self.setTask();
                 }
               })},
    

    But work in this :

    getTask: function() {
               var self = this;
               $("input").on("keydon", function(e) {
                  if(e.keyCode == 13) {
                    s.task = $(this).val();
                    self.setTask();
                 }
               })},
    

    Thanks for the help!

    Sooooooorrrrrryyyy, I did stupid mistake, misspelling in a variable.

    #165139
    __
    Participant
    s.textField.on("keydown", function(e) { // ...
    

    is s.textField a jQuery object?

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.