1,105,585 Community Members

Backbone - cannot understand why does not draw select html

Member Avatar
SPeed_FANat1c
Posting Pro
514 posts since Apr 2010
Reputation Points: 3 [?]
Q&As Helped to Solve: 18 [?]
Skill Endorsements: 0 [?]
 
0
 

Hello,

I am following this series

http://net.tutsplus.com/tutorials/javascript-ajax/build-a-contacts-manager-using-backbone-js-part-5/

and everything ws fine when was working with just javascrtript and html.

But now I want to put it together with php fraework and I cannnot get it to work.

It does not draw select box first of all. And does not draw contacts. Maybe if I would get the idea why it is not drawing select box, then I would undestand other things.

I commented out the code to figure out in which place things stop working.

js
http://pastebin.com/VLUdrJUE

html
http://pastebin.com/PNRKcbTD

I tried even this:

$('#filter').html('sasd');
this.$el.find("#filter").append('why this does not work?????');

but does not show any changes. But when I console.log that element it is found. So element selected but does not show any text/html. Why is this?

Member Avatar
CGSMCMLXXV
Junior Poster in Training
54 posts since Jan 2013
Reputation Points: 5 [?]
Q&As Helped to Solve: 7 [?]
Skill Endorsements: 0 [?]
 
0
 

Because of this:

this.$el

What is the intend of $el?

Member Avatar
SPeed_FANat1c
Posting Pro
514 posts since Apr 2010
Reputation Points: 3 [?]
Q&As Helped to Solve: 18 [?]
Skill Endorsements: 0 [?]
 
0
 

What is the intend of $el?

el: $("#contacts"),

I don't know what this

this.$el

means, I usually don't use such expessions, but as from tutorial there were sentences about catching or something like that - jquery cached version. I am not sure.

Member Avatar
SPeed_FANat1c
Posting Pro
514 posts since Apr 2010
Reputation Points: 3 [?]
Q&As Helped to Solve: 18 [?]
Skill Endorsements: 0 [?]
 
0
 

looks like I found the problem :D

but I don't get why is that. Nothing worked, so I eneded up deleting all html and all javascript because it has to start working at some point. So I have empty files.
Just made div #contacts, included jquery and app.js which I am wrinting.

in app.js only put the code

$(function() {
    // Stuff to do as soon as the DOM is ready;
        $('#contacts').html('sudas'); 
});

and finally it started to work :D wow. IF this would not have worked then I really would not understand.

So I Ctrl + Z both html and app.js files to get back where I was.

And I see the difference.

Original document ready was like this:

(function ($) {
...
} (jQuery));

But my wokring code was as you saw

 $(function() {

And this difeerence made it work. FML.

Can somebody explain what is the difference? I thoguht its the same document ready.
ANd how this could work earlier? I mean

(function ($) {

O, did quick google search
http://jquery-howto.blogspot.com/2008/12/what-heck-is-function-jquery.html

so it is for the reason to work with other libarries. But still why it could stop working for me?

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article