我有一個視圖,它包含另一個子視圖。但是當我點擊子視圖時,事件丟失了。我對木偶和骨幹莫代爾有點新,有人可以幫助我。骨幹模態與木偶意見 - 子視圖事件未被觸發
這裏是我的代碼片段。
主要觀點js文件
define(function(require) { 'use strict'; var BaseLayoutView = require('lib/views/baseLayout'), DialogExampleSubView = require('views/dialogExampleSub'), BaseRegion = require('lib/regions/baseRegion'), DialogExampleView; DialogExampleView = BaseLayoutView.extend({ template: 'dialogExample', initialize: function() { this.dialogSubView.attachNewView(DialogExampleSubView); }, hammerEvents : { 'tap .btn-default': 'testButton' }, testButton : function(e){ e.preventDefault(); e.stopPropagation(); console.log('hello button'); }, regions: { dialogSubView: { selector: '#testMiniView', regionClass: BaseRegion } } }); return DialogExampleView; });
子視圖js文件
define(function(require) { 'use strict'; var BaseView = require('lib/views/baseView'), vent = require('vent'), _ = require('underscore'), Marionette = require('marionette'), DialogExampleSubView; DialogExampleSubView = BaseView.extend({ template: 'dialogExampleSub', initialize: function() { Marionette.bindEntityEvents(this, this, this.events); }, events : { 'click .tooltip-test': 'testLinkClick' }, testLinkClick : function(e){ console.log('hello link click'); e.preventDefault(); e.stopPropagation(); } }); return DialogExampleSubView; });
當模態對話框顯示了只有 「testButton」 被炒,但 「testLinkClick」 是不是被解僱..會感謝你的幫助
我有點不情願幫助那些甚至沒有花5秒鐘清理他/她的代碼之前發佈在這裏的人。 – 2014-11-24 13:46:23
對不起亨利我現在打掃過了,我清理了我的評論,因爲我想分享我迄今爲止所嘗試過的內容。 – user1070229 2014-11-24 17:57:42