$ (...). jqxTooltip не является функцией - PullRequest
0 голосов
/ 13 октября 2019

Когда я использовал jqwidgets в сочетании с requirejs, у меня была проблема. Произошла ошибка $ (...). jqxTooltip не является функцией в консоли. Как вы решаете эту проблему? requirejs.config

requirejs.config({
  baseUrl:'/Scripts',
  paths: {
      jquery: 'jquery-3.4.1.min',
      jqx_tips: 'jqWidget/jqwidgets/jqxtooltip',
      tips: 'module/tips',
  }
})

Мой файл tips.js

define(['jquery','jqx_tips'], function ($,jqx_tips) {
return {
      attachment: function (entity) {
          if (entity.id == undefined || entity == null || entity.id == '') {
              throw 'Please Input Element Id';
              return;
          }
          if ($('#jqx_attachment')) {
              var html_attachment = '<i id="jqx_attachment"></i>';
              $('body').append(html_attachment);
          }
          $('#jqx_attachment').jqxTooltip({ content: 'The Amazing Spider-man', position: 'bottom'});
          $('#jqx_attachment').jqxTooltip('open');
      }
    }
});

Мой файл index.html

require(['jquery', 'tips'], function ($,tips) {
    $(function () {
        tips.attachment({id:'login_user'});
    });
})
...