Skip to content

Fix ReferenceError: newApi is not defined on dash pages#2265

Merged
ideav merged 2 commits intomainfrom
issue-2264-7dbd5d2a89dc
May 2, 2026
Merged

Fix ReferenceError: newApi is not defined on dash pages#2265
ideav merged 2 commits intomainfrom
issue-2264-7dbd5d2a89dc

Conversation

@konard
Copy link
Copy Markdown
Collaborator

@konard konard commented May 2, 2026

Root Cause

PR #2259 removed the duplicate <script src="/js/main.js"> from templates/dash.html. That script appeared redundant because main.html already loads main.js. However, main.html loaded main.js after the <!-- File: a --> placeholder where dash.html content (including <script src="/js/dash.js">) is injected.

Since browser scripts execute in DOM order, dash.js ran before main.js was loaded, leaving newApi undefined.

templates/main.html layout (before this fix):
  ...
  <main>
    <!-- File: a -->  ← dash.html injected here, including <script src="/js/dash.js">
  </main>
  <script src="/js/app.js"></script>
  <script src="/js/main-app.js"></script>
  <script src="/js/main.js"></script>  ← newApi defined here, but too late!

Fix

Move <script src="/js/main.js"> to before the <!-- File: a --> placeholder in templates/main.html. This ensures newApi is defined before any page-specific script runs.

templates/main.html layout (after this fix):
  ...
  <script src="/js/main.js"></script>  ← newApi defined here ✓
  <main>
    <!-- File: a -->  ← dash.js runs, newApi already available ✓
  </main>
  <script src="/js/app.js"></script>
  <script src="/js/main-app.js"></script>

How to verify

  1. Open any dash page in the CRM
  2. Open DevTools Console — the Uncaught ReferenceError: newApi is not defined error should be gone
  3. The dashboard should load and function normally

Fixes #2264

Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: #2264
@konard konard self-assigned this May 2, 2026
After PR #2259 removed the duplicate main.js load from dash.html,
dash.js no longer had newApi available because main.html injected
the template content (including dash.js) before loading main.js.

Move main.js to load before the <!-- File: a --> placeholder so
newApi is defined before any page-specific script executes.
@konard konard changed the title [WIP] https://github.com/ideav/crm/pull/2259 Ошибка Fix ReferenceError: newApi is not defined on dash pages May 2, 2026
@konard konard marked this pull request as ready for review May 2, 2026 16:30
@konard
Copy link
Copy Markdown
Collaborator Author

konard commented May 2, 2026

Working session summary

Root cause: PR #2259 removed <script src="/js/main.js"> from dash.html assuming it was a duplicate, but main.html loads main.js after the <!-- File: a --> placeholder where dash.html (and its <script src="/js/dash.js">) is injected. Since browsers execute scripts in DOM order, dash.js ran before main.js, leaving newApi undefined.

Fix: Moved <script src="/js/main.js"> in templates/main.html to just before the <!-- File: a --> placeholder (one line change, moving it earlier in the file), ensuring newApi is defined before any page-specific script executes.

PR: #2265


This summary was automatically extracted from the AI working session output.

@konard
Copy link
Copy Markdown
Collaborator Author

konard commented May 2, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $0.553277

📊 Context and tokens usage:

  • 39.9K / 1M (4%) input tokens, 8.2K / 64K (13%) output tokens

Total: (809 new + 29.4K cache writes + 1.1M cache reads) input tokens, 8.2K output tokens, $0.553277 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: sonnet
  • Model: Claude Sonnet 4.6 (claude-sonnet-4-6)

📎 Log file uploaded as Gist (1003KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@ideav ideav merged commit 9af96b2 into main May 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

https://github.com/ideav/crm/pull/2259 Ошибка

2 participants