mirror of
https://github.com/filp/whoops.git
synced 2026-09-13 03:06:20 +00:00
Use event delegation.
This way, we avoid binding the event handler to all lines. Instead, we bind to the container and simply pass on control to the targeted frame.
This commit is contained in:
@@ -3,7 +3,6 @@ Zepto(function($) {
|
||||
|
||||
var $frameContainer = $('.frames-container');
|
||||
var $container = $('.details-container');
|
||||
var $frameLines = $frameContainer.find('.frame');
|
||||
var $activeLine = $frameContainer.find('.frame.active');
|
||||
var $activeFrame = $container.find('.frame-code.active');
|
||||
var headerHeight = $('header').height();
|
||||
@@ -22,7 +21,7 @@ Zepto(function($) {
|
||||
// Highlight the active for the first frame:
|
||||
highlightCurrentLine();
|
||||
|
||||
$frameLines.click(function() {
|
||||
$frameContainer.delegate('.frame', 'click', function() {
|
||||
var $this = $(this);
|
||||
var id = /frame\-line\-([\d]*)/.exec($this.attr('id'))[1];
|
||||
var $codeFrame = $('#frame-code-' + id);
|
||||
|
||||
Reference in New Issue
Block a user