Skip to main content

Posts

Showing posts from October, 2013

What does jquery prototype or fn mean

All objects have a  prototype  property. It is simply an object from which other objects can inherit properties. The snippet you have posted simply assigns an object with some properties (such as  init ) to the  prototype  of  jQuery , and aliases  jQuery.prototype  to  jQuery.fn  because  fn  is shorter and quicker to type. If you forget about jQuery temporarily, consider this simple example: function Person ( name ) { this . name = name ; } Person . prototype . sayHello = function () { alert ( this . name + " says hello" ); }; var james = new Person ( "James" ); james . sayHello (); // Alerts "James says hello" In this example,  Person  is a  constructor  function. It can be  instantiated  by calling it with the  new operator. Inside the constructor, the  this  keyword refers to the instance, so every instance has its own name  property. The  prototype  of  Person  is shared between all instances. So all instances of  P

Django template page still show html tags (html tag is not parsed)

Sometime, you use variable {{content}} in the template page. you may find that html tags in {{content}} (e.g.," <em> ABC </em>" ) are still shown in Web page. Html tags are not parsed. The solution is to use "safe" filter in Django template. change  {{content}} to  {{ content | safe}} reference: https://code.djangoproject.com/wiki/AutoEscaping