jQuery选择问题

时间:2015-09-07 18:58:40

标签: javascript jquery html angularjs

我试图在(cropper example)视图中使用此示例AngularJS图像裁剪器应用程序的代码,但它没有用。我认为问题在于元素选择。

这就是我正在做的事情:

主要应用程序HTML

<div class="view-container layer">
    <div class="container content" ng-view>
        <!-- load the content of the view--!>
    </div>
</div>

视图

这是示例(view)的正文部分中的代码。我省略了整个代码;我只是包括主要部分。

<div class="container" id="crop-avatar">
    <!-- the div content --!>
</div>

The JavaScript selectors

function CropAvatar($element) {
    this.$container = $element;

    this.$avatarView = this.$container.find('.avatar-view');
    this.$avatar = this.$avatarView.find('img');
    this.$avatarModal = this.$container.find('#avatar-modal');
    this.$loading = this.$container.find('.loading');

    this.$avatarForm = this.$avatarModal.find('.avatar-form');
    this.$avatarUpload = this.$avatarForm.find('.avatar-upload');
    this.$avatarSrc = this.$avatarForm.find('.avatar-src');
    this.$avatarData = this.$avatarForm.find('.avatar-data');
    this.$avatarInput = this.$avatarForm.find('.avatar-input');
    this.$avatarSave = this.$avatarForm.find('.avatar-save');
    this.$avatarBtns = this.$avatarForm.find('.avatar-btns');

    this.$avatarWrapper = this.$avatarModal.find('.avatar-wrapper');
    this.$avatarPreview = this.$avatarModal.find('.avatar-preview');

    this.init();
}

CropAvatar初始化为:

$(function () {
    return new CropAvatar($('#crop-avatar'));
});

如果我使用此表单中的代码,它根本不起作用,但如果我将所有HTML代码放入mi app.html的<body></body>标记中,它就可以正常工作。由于这个原因,我认为这是一个选择问题。

0 个答案:

没有答案