last day (14 days later) » 

18:57
1
A: Dynamically set child View $el and have Backbone events fire

JackEvery view has a associated el, whether you set it directly or not, if you don't set it then it's el is just a empty div. In your code you aren't modifying your child view's el or attaching it to the DOM. Try the following render: function(){ this.template = _.template($('#rep-template').ht...

these views aren't dynamic though. You are only calling #rep-template, not something like #rep-template-dynamicNumber1 or #rep-template-dynamicNumber32, hence why I am attaching the unique identifier to the DOM ID
I'm not sure what you are trying to do, but If you pass in a el then that element must exist on the page at that point, if you want a unique id you can always assign the id from within your view. I've updated the fiddle to illustrate.
Further what you probably want is for your parent view to create the child view's and attach them, something like the following jsfiddle.net/KqrF9/74
So you are using the shortcut $el to get the jquery element, (which when instantiated, was just the empty div), then setting the id on it. you then compile the template and put the compiled template into the child view, and append it where it says to. I think I was trying to put the id in the compiled template, so i think that was the problem, right?
Never heard of a template key, so if I want to use it, does it have to have all the same values in the compiled template, or can they be different, as long as the structure of the HTML template is the same?
Not sure what you mean by key, but if you mean compiled then yes you can just pass in the values you want and interpenetrate them.
Regarding setting the id of the el, you might also want to specify the class in your view (you can use the className property for that) and then get rid of the outer div in your template since it is probably extra (inspect the resulting HTML and you should see what I mean).
I mean key from key:value
since the views and models are associative arrays
so template: .... is key:value
19:00
Well sort of, it's a function. When you pre-compile it you are saving a reference to the resulting function.
I appreciate your help. I am trying to get a fiddle up and running to ultimately find out how to properly delete a view, since that is the ultimate problem in our app...
You can then just pass in different values each time, for example you may have seen something like myTemplate(this.model.toJSON())
Why can't you just call remove in the view?
this problem doesnt exist in our actual app, so I am learning the different ways to assign the el
ive noticed that others use this.model.toJson()
we havent used that
we are somewhat broken and trying to fix stuff
our views contain some data
the ultimate bottle nexk is that the views are SVGs
Something like this jsfiddle.net/KqrF9/75
You can also maintain a reference in your parent view to the created child views (i did that in the same fiddle)
reviewing.....
so on the parent view you are adding a views array
then when you add, you create a child view from the parent view, and add it to the array
in the child view, if you want to remove it, you call this.remove(), and it SHOULD remove itself from the parent array?
I am having difficulty seeing the views array
how would I attach the views{} to the window for inspection
19:12
Actually not exactly, if you maintain a reference in the parent view you will need to be careful that you don't end up with a zombie reference (do a search on zombie views to get a better idea), you can listen to the remove event in the parent view to do some cleanup if nesseary.
ususally I would do something like window.csf = this.views; but that isnt working, as I want to see the view object, not the model attributes
If you set a breakpoint somewhere in your view you should be able to see it
that makes sense
i know about zombies and we have many of them!
You might also find the following extension helpful for analyzing your backbone application dhruvaray.github.io/spa-eye
im tempted to throw away everything and start from scratch. I started BBone a year ago, two months after starting to code. learned so much, so much to fix!
Thanks for the help
I will review this information more thoroughly with my new coding partner/researcher
what do you call an alligator in a vest?
19:17
No problem, I didn't fully go through your code so there are probably some other things you can optimize there.
the template thing is a big heads up.... , also with the realization that i need to move more things to the model, and not rely on them in the view....
An investigator!
or a snappy dresser!
have a wonderful day, and remaining of the week
Same to you. Good luck.

last day (14 days later) »