this.$el .prototype .proxy

this.$el = $( ‘<div class=”gr-room”><div class=”gr-wall-main”><div class=”gr-floor”></div></div></div>‘ ).insertAfter( $itemsContainer );

  •  4 walls (or 1 if no support for 3dtransforms)
  • adjust the value of the perspective according to the value of the current window’s width

$(this.el) wraps an element with jQuery. So, if your view HTML was this:

<div id="myViewElement"></div>

…and this.el referenced that div, then $(this.el) would be the equivalent of retrieving it directly via jQuery: $('#myViewElement').

In JavaScript, the prototype is the mechanism which provides inheritance (as opposed to, say, classes). Example:String.prototype refers to the prototype object of Strings, which contains (among other things) methods which can be invoked on any String.

$('ul li').each(function()
{
    $(this).width();
});

This is far more simple to walk over a set of elements with the .each() function.

jQuery.proxy( function, context [, additionalArguments ] )

This method is most useful for attaching event handlers to an element where the context is pointing back to a different object. Additionally, jQuery makes sure that even if you bind the function returned from jQuery.proxy() it will still unbind the correct function if passed the original.

It allows us the ability to force a particular context when calling a method. In JavaScript, there can be times when it’s difficult to hold on to the this keyword. For example, when it’s bound to some event handler, this now refers to the target of the handler, rather than your desired object.

jquery append script to html element dynamically

The .append() method inserts the specified content as the last child of each element in the jQuery collection (To insert it as the first child, use .prepend()).

<h2>Greetings</h2>
<div class="container">
<div class="inner">Hello</div>
<div class="inner">Goodbye</div>
</div>
$(‘.inner’).append(‘<p>Test</p>’); // append()前面是要选择的对象后面是要在对象内插入的元素内容
<h2>Greetings</h2>
<div class="container">
<div class="inner">
Hello
<p>Test</p>
</div>
<div class="inner">
Goodbye
<p>Test</p>
</div>
</div>

The .append() and .appendTo() methods perform the same task. The major difference is in the syntax-specifically, in the placement of the content and target:

  • With .append(), the selector expression preceding the method is the container into which the content is inserted.
  • With .appendTo(), on the other hand, the content precedes the method, either as a selector expression or as markup created on the fly, and it is inserted into the target container.

$(‘<p>Test</p>’).appendTo(‘.inner’); //appendTo()前面是要插入的元素内容,而后面是要选择的对象

this.$navPrev = $( ‘<span class=”gr-prev”>prev</span>’ ).on( ‘click’, $.proxy( this.navigate, this, ‘prev’ ) );
this.$navNext = $( ‘<span class=”gr-next”>next</span>’ ).on( ‘click’, $.proxy( this.navigate, this, ‘next’ ) );
this.$nav = $( ‘<nav/>’ ).append( this.$navPrev, this.$navNext ).appendTo( $gallery );

// add caption container
this.$caption = $( ‘<div class=”gr-caption”><span class=”gr-caption-close”>x</span></div>’ ).appendTo( $gallery );
this.$caption.find( ‘span.gr-caption-close’ ).on( ‘click’, $.proxy( this.hideDescription, this ) );

<nav/>

<span class=”gr-prev”>prev</span><span class=”gr-next”>next</span>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

生活在西班牙

自己动手丰衣足食

BlueAsteroid

Just another WordPress.com site

Jing's Blog

Just another WordPress.com site

Start from here......

我的心情魔方

天才遠私廚

希望能做一個分享各種資訊的好地方

语义噪声

西瓜大丸子汤的博客

笑对人生,傲立寰宇

Just another WordPress.com site

Where On Earth Is Waldo?

A Project By Melanie Coles

the Serious Computer Vision Blog

A blog about computer vision and serious stuff

Cauthy's Blog

paper review...

Cornell Computer Vision Seminar Blog

Blog for CS 7670 - Special Topics in Computer Vision

datarazzi

Life through nerd-colored glasses

Luciana Haill

Brainwaves Augmenting Consciousness

槑烎

1,2,∞

Dr Paul Tennent

and the university of nottingham

turn off the lights, please

A bunch of random, thinned and stateless thoughts around the Web

%d bloggers like this: