시험해보세요. 최근에 내 개인 프로젝트에서이 작업을 수행했습니다.
여기
Ember.View.extend({
init: function() {
this._super();
this.get('parentView').registerInfoWindow(this);
this.get('googleInitializer.library').then(function() {
this.set('infoWindow', new google.maps.InfoWindow({
content: $('<div></div>')[0]
}));
google.maps.event.addListener(this.get('infoWindow'), 'closeclick', function() {
this.set('open', false);
}.bind(this));
}.bind(this));
},
classNames: 'hidden',
tagName: 'div',
map: Ember.computed.alias('parentView.map'),
marker: Ember.computed.alias('parentView.marker'),
infoWindow: null,
open: false,
onOpenChange: function() {
if (this.get('infoWindow')) {
if (this.get('open')) {
this.get('infoWindow').open(this.get('map'), this.get('marker'));
} else {
this.get('infoWindow').close();
}
}
}.observes('open'),
detachedDom: null,
onWindowContentReady: function() {
if (this.get('infoWindow') && this.get('detachedDom')) {
this.get('infoWindow').setContent(this.get('detachedDom'));
}
}.observes('infoWindow', 'detachedDom'),
didInsertElement: function() {
this.set('detachedDom', this.$().detach()[0]);
}
});
은 본질적으로 여기에 무슨 일이 일어나고 있는지 나는 즉시 그 생성 된 DOM을 분리하고있어 것입니다 내 정보창보기입니다. 나중에 infoWindow가 준비되면 infoWindow의 내용을 설정합니다. html이 렌더링되고 버튼 액션 이벤트가 유지됩니다. 더 이상 고급 ember 바인딩을 시도하면 어떻게 될지 잘 모르겠습니다. 나는이 일을하고있어, 그래서 나는 내 자신을 들여다보고있다.
이런 식으로 일을의 장점은, 내가이이
{{#view 'google-maps' markers=fixtureCollection}}
{{#with view.markerController}}
{{#each}}
{{#view 'marker' coords=this}}
{{#view 'infoWindow'}}
<div>
<h2>Hello World</h2>
<button {{action 'doSomething'}}>Foo</button>
</div>
{{/view}}
{{/view}}
{{/each}}
{{/with}}
{{/view}}
감사처럼 내 템플릿을 작성할 수 있다는 것입니다. 나는 단지 그것을 보았습니다 (내 이메일 알림을 꺼야한다고 생각합니다). 나는 그것을 점검하고 내가 어떻게 시작하는지 알려줄 것이다. – mickyginger