I'm currently diving into backbone fundamentals and feeling a bit lost with the following line of code:
this.$input = this.$('#new-todo');
Can someone explain to me what exactly is happening here?
As far as I can tell, this.$('#new-todo')
seems like a standard jQuery selector that targets the #new-todo
(which is an input field) and assigns it to this.$input
. According to this resource, $(this + 'input') is just a shorthand for this, but this is where I am confused - why is that necessary? Is it simply moving the #new-todo
element from the DOM to $(this + 'input')? If so, wouldn't it be more straightforward to use this.$('something') instead of this.$input?