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

qbYJeZ

A Pen By Captain Anonymous

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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