ember or showdown : Uncaught TypeError: Cannot call method 'replace' of undefined

StackOverflow https://stackoverflow.com/questions/16128463

  •  11-04-2022
  •  | 
  •  

Domanda

Tom Dayle's Lecture: Intro to Ember
http://www.youtube.com/watch?feature=player_embedded&v=Ga99hMi7wfY

i used both github.com/cmoel/tom_dale_embe­r_screencast github.com/cmoel/tom_dale_ember_screencast And
github.com/jielimanyili/tom-dale-screencast_building-an-app-with-ember-js_code

In Chrome Dev: Uncaught TypeError: Cannot call method 'replace' of undefined (showdown.js:62)
If i remove the use of "markdown" from the template.. the App works.

In FireBug: a is undefined (showdown.js: 62)

Not sure if it is Ember or Showdown that is causing this.

Thanks

È stato utile?

Soluzione 2

I think you will be...little angry... this was just a typo I think... in the template you refer {{extended}}, but in the fixtures, the property is extentded. So obviously the Showdown plugin complains because you're trying to use it with undefined.

http://jsfiddle.net/Sly7/7vfLD/7/

Altri suggerimenti

I too followed Tom Dale's youtube video and seemed to get this error only when I refresh the page while on the #/posts/1 (posts/post route).

I managed to resolve this issue by skipping the showdown conversion in the registerBoundHelper, like so:

var showdown = new Showdown.converter();
Ember.Handlebars.registerBoundHelper('markdown', function(input) {

  // Add this part
  if (typeof input == 'undefined')  return;

  return new Ember.Handlebars.SafeString(showdown.makeHtml(input));
});
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top