samedi 26 septembre 2015

Ember - How to change the height of a panel from a controller?

I'm trying to change the height of a panel in an ember .hbs file from it's controller. I've seen lots of examples, but I can't seem to get things right. Here's a jsbin I put together for it, and following that is my code. Any help will be much appreciated. Thanks!

version: 1.13.8 node: 0.12.7 npm: 2.13.4 os: win32 x64

http://ift.tt/1gYfm4e

HTML

    <!DOCTYPE html>
    <html>
    <head>
        <script src="http://ift.tt/1sNUv3Z"></script>
        <link href="http://ift.tt/1K1B2rp" rel="stylesheet" type="text/css" />
        <script src="http://ift.tt/1InYcE4"></script>
        <script src="http://ift.tt/1JP22ba"></script>
        <meta charset="utf-8">
        <title>Ember Starter Kit</title>
        <link rel="stylesheet" href="http://ift.tt/1x2iORp">
        <script src="http://ift.tt/1VfQY14"></script>
        <script src="http://ift.tt/1gYfl0n"></script>
    </head>
    <body>
        <script type="text/x-handlebars">
        <div class="panel panel-primary" id="linkPanel" style="width:205px;">
            <div class="panel-heading">
                <h3 class="panel-title">Stuff</h3>
            </div>
            <div class="panel-body">
                Blah blah blah...
            </div>
            <div>
                <button style="margin: 10px;" {{action "addHeight"}}>Add Stuff</button>
            </div>
        </div>
        </script>
    </body>
    </html>

Controller (JS)

App = Ember.Application.create();
App.Router.map(function() {
// put your routes here
});

App.ApplicationController = Ember.Controller.extend({
  actions: {
    addHeight: function() {

// My goal here is to be able to increase the height
// of the panel "#linkPanel" from an action.

// In this version, I'm just trying to see
// if I can reference the panel (I can't.)

// In the commented out lines, I was trying
// to actually change it.

// Any help and/or advice will be much appreciated.

alert(document.getElementById('#linkPanel'));

//this.set('this.document.getElementById('#linkPanel').height',"500px");

//this.set('this.document.getElementById('#linkPanel').style.height',"500px");

//this.set('document.getElementById('#linkPanel').style.height',"500px");

//this.set('document.getElementById('#linkPanel').style.width',"500px")

     //this.set('document.getElementById('#linkPanel').style',"Height=500px")

    } 
  }
});




Aucun commentaire:

Enregistrer un commentaire