最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - ERROR TypeError: "jit_nodeValue_3(...).toggle is not a function" - Stack Overflow

programmeradmin0浏览0评论

I'm working on an Angular project. I wanted to add a month picker that would turn up on click of a text field at the nav bar. I'm using primeng ponents like <p-calendar> and <p-overlay>. Its a huge project in itself and I've to add calendar widget. So I'll show you my part of code only.

navigationponent.html

<div class="dls-menu-item" style="float: right; margin-right: 200px;">
    <input type="text" (click)="op.toggle($event)">
</div>

<p-overlayPanel #op>
  <div id="p-render">
    <div class="all-container">
      <p>Time selection</p><br>
      <div>
        <p-calendar view="month" dateFormat="mm/yy"...></p-calendar>
      </div>
      <br>
    </div>
  </div>
</p-overlayPanel>

But the moment I click on the input field, I get this error:

My research on this error says that it is related to MD Bootstrap. But this answer is not working for me. I also tried this technique but it's not performing the way we want. And my findings says that (click)="op.toggle($event) is the root cause. Please tell me how to solve this.

I'm working on an Angular project. I wanted to add a month picker that would turn up on click of a text field at the nav bar. I'm using primeng ponents like <p-calendar> and <p-overlay>. Its a huge project in itself and I've to add calendar widget. So I'll show you my part of code only.

navigation.ponent.html

<div class="dls-menu-item" style="float: right; margin-right: 200px;">
    <input type="text" (click)="op.toggle($event)">
</div>

<p-overlayPanel #op>
  <div id="p-render">
    <div class="all-container">
      <p>Time selection</p><br>
      <div>
        <p-calendar view="month" dateFormat="mm/yy"...></p-calendar>
      </div>
      <br>
    </div>
  </div>
</p-overlayPanel>

But the moment I click on the input field, I get this error:

My research on this error says that it is related to MD Bootstrap. But this answer is not working for me. I also tried this technique but it's not performing the way we want. And my findings says that (click)="op.toggle($event) is the root cause. Please tell me how to solve this.

Share edited Dec 13, 2019 at 7:44 Tony 20.2k7 gold badges41 silver badges62 bronze badges asked Nov 12, 2019 at 5:34 TanzeelTanzeel 5,05824 gold badges85 silver badges159 bronze badges 2
  • toggle is jquery function right ? – Tony Commented Nov 12, 2019 at 6:34
  • @TonyNgo. Yes it is. It is also in typescript. The above is a template code directly from the primeng documentation. They've written it that way. Here is the link primefaces/primeng/#/overlaypanel – Tanzeel Commented Nov 12, 2019 at 6:48
Add a ment  | 

4 Answers 4

Reset to default 3

This happens when you try to trigger the popover toggle from a non-prime element. It appears you need to add pInput to the input (or div and move the click handler) and then it will work.

<div class="dls-menu-item" style="float: right; margin-right: 200px;">
    <input type="text" (click)="op.toggle($event)" pInput><!--Add pInput-->
</div>

<p-overlayPanel #op>
  <div id="p-render">
    <div class="all-container">
      <p>Time selection</p><br>
      <div>
        <p-calendar view="month" dateFormat="mm/yy"...></p-calendar>
      </div>
      <br>
    </div>
  </div>
</p-overlayPanel>

Sorry for late reply can you try to create typings.d.ts and put this code here into it

interface JQuery<any> {
    tooltip(params: any): any;
}

Then in your tsconfig.json

"typeRoots": [
            "node_modules/@types",
            "src/typings.d.ts" // add here
        ],

Please check that ngx-menu is imported in your module in which you are using it. Basically if you are using multiple module and if you are not importing it in the module in which you are using ngx-menu then it will throw this error. So import ngx-menu in that specific module to solve this error. :)

I recently encountered console error jit_nodevalue_3(...) is not a function while using Angular 7 and Mat-Menu.

The reason behind this error was the mat-menu element being declared with the same name as a click handler function I was using.

<mat-menu #onClickItem="matMenu">
  <button mat-menu-item (click)="onClickItem()">Item 1</button>
  <button mat-menu-item>Item 2</button>
</mat-menu>

Renaming the click function solved the problem.

<button mat-menu-item (click)="doSomething()">Item 1</button>

Hope this helps someone.

发布评论

评论列表(0)

  1. 暂无评论