Skip to content

Fix: Replace jQuery utilities with ES6+ in site templates#680

Merged
wenzhixin merged 1 commit into
developfrom
fix/issue-677-jquery-trim
Feb 28, 2026
Merged

Fix: Replace jQuery utilities with ES6+ in site templates#680
wenzhixin merged 1 commit into
developfrom
fix/issue-677-jquery-trim

Conversation

@wenzhixin

Copy link
Copy Markdown
Owner

🤔 Type of Request

  • Bug fix
  • New feature
  • Improvement
  • Documentation
  • Other

🔗 Resolves an issue?

Fixes #677 - View source code not working after jQuery upgrade

📝 Description

This PR fixes the broken "View Source" functionality by replacing deprecated jQuery utility methods with ES6+ alternatives in the site templates.

After jQuery was upgraded to the latest version, $.trim() and other utility methods were removed, causing the view source feature to fail.

🎯 Changes

1. site/website/static/js/template.js

  • $.trim()String.prototype.trim()
  • $.map()Array.prototype.map()
  • $.each()Array.prototype.forEach()
  • $.extend()Object.assign()
  • $.param() → Manual URL parameter encoding

2. site/website/static/templates/refresh.html

  • $.trim($input.val())$input.val().trim()

✅ Testing

  • All lint checks pass
  • Manual testing of view source functionality
  • No breaking changes to existing functionality

📊 Files Modified

  • site/website/static/js/template.js - 8 replacements
  • site/website/static/templates/refresh.html - 1 replacement

Love multiple-select? Please consider supporting us:
👉 https://opencollective.com/multiple-select/donate

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR restores the “View Source” functionality in the website templates after a jQuery upgrade by replacing removed/deprecated jQuery utility helpers with ES6+ equivalents.

Changes:

  • Replaced $.trim/$.map/$.each/$.extend usage in the view-source templating logic with native trim, map, forEach, and Object.assign.
  • Replaced $.param with manual query-string construction for the AJAX URL.
  • Updated the refresh template to use native string trimming on the input value.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
site/website/static/js/template.js Migrates jQuery utility usage to ES6+ to keep view-source rendering and init wiring working post-upgrade.
site/website/static/templates/refresh.html Removes dependency on $.trim() in the refresh example by using native .trim().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread site/website/static/js/template.js Outdated
Fixes #677 - View source code not working after jQuery upgrade

Changes:
- Replace $.trim() with String.prototype.trim()
- Replace $.map() with Array.prototype.map()
- Replace $.each() with Array.prototype.forEach()
- Replace $.extend() with Object.assign()
- Replace $.param() with URLSearchParams implementation

This ensures compatibility with jQuery 4.0+ where utility methods
like $.trim() have been removed.

Files modified:
- site/website/static/js/template.js
- site/website/static/templates/refresh.html

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

site/website/static/js/template.js:172

  • Object.assign({...}, options_) will throw a TypeError if window.init is ever called with null or undefined (whereas the previous $.extend call tolerated that). Consider defaulting options_ to an empty object (or conditionally assigning) to keep the initializer resilient.
window.init = function (options_) {
  var options = Object.assign({
    title: '',
    desc: '',
    links: [],
    scripts: [],
    bootstrapVersion: 3,
    callback: function () {
      if (typeof window.mounted === 'function') {
        window.mounted()
      }
    }
  }, options_)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@wenzhixin wenzhixin merged commit e8448fa into develop Feb 28, 2026
5 checks passed
@wenzhixin wenzhixin deleted the fix/issue-677-jquery-trim branch February 28, 2026 04:37
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.

🔴 Multiple Select view source code is not working, We cannot see the view source code.

2 participants