cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Untitled

A Pen By Captain Anonymous

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <html>

<head>
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.min.js"></script>
  
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.0/underscore-min.js"></script>
  
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.2.3/backbone-min.js"></script>
  
</head>

<body>
  <div id="hideable">
    <a href="#" class="hide">Hide Me</a>
  </div>
  <p id="message">Hello</p>
</body>

</html>
            
          
!
            
              //Create a HideableView "sub-class" of Backbone.View
var HideableView = Backbone.View.extend({
  el: '#hideable', //the view will bind to this selector
  events: {
    'click .hide': 'hide'
  },
  //this function was referenced in the click handler above
  hide: function() {
    //hide the entire view
    $(this.el).hide();
  }
});

var hideable = new HideableView();

var HideableTableView = HideableView.extend({
  //Some view that is hideable and rendered as a table.
});

var HideableExpandableView = HideableView.extend({
  initialize: function() {
    //add an expand click handler. We didn't create a separate
    //separate events object because we need to add to the
    //inherited events.
    this.events['click .expand'] = 'expand';
  },
  expand: function() {
    //handle expand
  }
});

var table = new HideableTableView();
var expandable = new HideableExpandableView();

//We should see "expand" in the console"
console.log(table.events['click .expand']);

//alternatively, show somewhere on the page too
$('#message').html(table.events['click .expand']);
            
          
!
999px
Loading ..................

Console