freejacque / project_three_app

0 stars 0 forks source link

Can't figure out how to get a template to render. #2

Closed freejacque closed 10 years ago

freejacque commented 10 years ago

I'm trying to use todo.ly as an example but I still don't completely understand how it works. I could use some guidance on getting the template to render objects. this is my template:

ghost commented 10 years ago

Hi Jackie! You didn't actually add your code. Can you push your project currently and paste into this issue the:

freejacque commented 10 years ago

javascript.js

function Card(element){ this.element = element; // this.atomicNumber = element.atomicNumber; // this.name = element.name; // this.symbol = element.symbol; // this.electronConfiguration = element.electronConfiguration; // this.category = element.category; // this.charge = element.charges[0]; // this.charge2 = element.charges[1]; }

Card.prototype = { template: _.template($("#card-template").html()),

render: function(){
  console.log(' view:render', this);
  var temp = this.template({element: this.element});
  this.$element = $(temp);

  return this;
},

init: function(){
  console.log(' view:init', this);
  var view = this;
  if (!this.$element){
    view.render();
    $("#card").append(view.$element);
    console.log(this.$element);
  }
},

};

freejacque commented 10 years ago

index.html

<!doctype html>

``` project_three_app ```

Hello from Index.html!

freejacque commented 10 years ago

I'm not sure if I do have the code that is rendering the template because I don't understand how it works.

ghost commented 10 years ago

Cool. Remember to put the code in code brackets like this:

```ruby
...
...

... or ...
<p>HTML goes here!</p>


Now -- I need you to do that with your HTML. Markdown renders HTML as is, so I can't actually see your code!
ghost commented 10 years ago

Example:

ghost commented 10 years ago

Coolio.