2012-05-22 12 views
5

Emberで必要なときに再利用するためのダイアログのようなコントロールを作成したいと思います。ダイアログは$( 'foo')を使用します。それを実装するためにJqueryライブラリのダイアログ関数。 E.x:Emberでダイアログのようなコントロールを作成するには?

dialog control in Ember

はあなたが私に任意のアイデアや例を与えることができます。ありがとう。

答えて

9

Luke Meliaさんは、012berさんのjQuery UIでの使い方を示すrepositoryを作成しました。

ベースルカの例で、私はhttp://jsfiddle.net/pangratz666/aX7x8/を参照してください、jQueryのUIのダイアログを表しJQ.Dialogクラスを作成しました:

// Create a new mixin for jQuery UI widgets using the Ember 
// mixin syntax. 
JQ.Widget = Em.Mixin.create({ 
    // as defined in 
    // https://github.com/lukemelia/jquery-ui-ember/blob/master/js/app.js#L9-95 
    ... 
}); 

JQ.Dialog = Ember.View.extend(JQ.Widget, { 
    uiType: 'dialog', 
    uiOptions: 'autoOpen height width'.w(), 

    autoOpen: false, 

    open: function() { 
     this.get('ui').dialog('open'); 
    }, 
    close: function() { 
     this.get('ui').dialog('close'); 
    } 
}); 

ダイアログは、このように作成されます。

var dialog = JQ.Dialog.create({ 
    height: 100, 
    width: 200, 
    templateName: 'dialog-content' 
}); 
dialog.append(); 

Ember.run.later(function(){ 
    dialog.open(); 
}, 1000); 


jQuery UI以外にも、flame.js、Ember.js用のウィジェット/ UIライブラリ

// the following code sample has been taken from http://jsfiddle.net/qUBQg/ 
App.TestPanel = Flame.Panel.extend({ 
    layout: { width: 400, height: 200, centerX: 0, centerY: -50 }, 
    // Controls whether all other controls are obscured (i.e. blocked 
    // from any input while the panel is shown) 
    isModal: true, 
    // This controls the visual effect only, and works only if 
    // isModal is set to true 
    dimBackground: true, 
    // Set to false if you want to e.g. allow closing the panel only 
    // by clicking some button on the panel (has no effect if isModal 
    // is false) 
    allowClosingByClickingOutside: true, 
    // Allow moving by dragging on the title bar - default is false 
    allowMoving: true, 
    // Title is optional - if not defined, no title bar is shown 
    title: 'Test Panel', 

    // A Panel must have exactly one child view named contentView 
    contentView: Flame.LabelView.extend({ 
     layout: { left: 20, top: 90, right: 20, bottom: 20 }, 
     textAlign: Flame.ALIGN_CENTER, 
     value: 'This is a panel.' 
    }) 
}); 

// later in the code 
App.TestPanel.create().popup(); 
+0

ありがとうpangratz、しかし、私はちょうどjQueryライブラリのダイアログが(「foo」を)$を使用してのような簡単なダイアログを作成する:このプロジェクトは、パネルのサポートを持っている、http://jsfiddle.net/qUBQg/を参照してください。あなたは私に何かアイデアを教えていただけますか? – secretlm

+0

さて、あなたはあなたの質問を精緻化するべきです。それを更新し、実際に何をしたいかを追加してください... – pangratz

+0

ありがとう、pangratz。 – secretlm

関連する問題