【问题标题】:jQueryUI events not working with Angularjs,navigates on clickjQuery UI 事件不适用于 Angularjs,点击导航
【发布时间】:2014-08-08 08:48:42
【问题描述】:

我正在开发一个基于 angularjs 的应用程序,其中我有一些 jQueryUI 控件。我的页面有一个可折叠/可扩展的导航面板。单击它会展开并显示菜单并在再次单击时滑回(切换)但是当我使用角度页面执行此操作时,我的 url 会重定向到其他情况(默认页面)。如果我使用事件。 stoppropagation 我的 jQuery 控件停止工作并且切换功能不起作用。 我也尝试过 HTML 模式,但没有成功。下面是我的 app.js(用于路由)和 HTML,其中 MENU 调用菜单项的切换。任何想法都会有很大帮助。

$routeProvider
 .when('/', {templateUrl: 'app/views/login.html', controller:'loginCtrl'})
  .when('/overview', {templateUrl: 'app/views/overviewDashboard.html', controller:'overviewDashboardCtrl'})
  .when('/changepassword', {templateUrl: 'app/views/changePassword.html', controller:'changePasswordCtrl'}) 
  .when('/discoverysettings', {templateUrl: 'app/views/discoverySettings.html', controller:'discoveryCtrl'}) 
  .when('/managedObject', {templateUrl: 'app/views/managedObject.html',controller:'managedObjectCtrl'}) 

  .when('/search', {templateUrl: 'app/views/search.html'}) 
   .otherwise({ redirectTo: '/overview' });

HTML 是

                <aside class="left clear side-menu expanded">
            <a href="#" target="_self" class="menu-controller" >MENU</a>

            <nav role="navigation" class="side-nav">
            <ng:include src="'app/views/sidebar.html'"></ng:include>

            </nav><!-- end side-nav -->
        </aside>

【问题讨论】:

    标签: jquery angularjs jquery-ui


    【解决方案1】:

    幸运的是,我在jQuery click events not firing within AngularJS templates 得到了答复。

    用以下格式替换 jQuery 事件解决了这个问题。

    $(document).on("click", ".clickme", function() {
      console.log("click");
    });
    

    html 的变化

    <a href="#" target="_self" class="menu-controller">MENU</a>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-07-29
      • 1970-01-01
      • 2011-10-12
      • 1970-01-01
      • 1970-01-01
      • 2013-06-24
      • 2017-06-10
      相关资源
      最近更新 更多