Uncaught TypeError: $(...).once is not a function

Created on 21 April 2023, about 1 year ago
Updated 3 May 2024, about 2 months ago

Problem/Motivation

Noticing console error Uncaught TypeError: $(...).once is not a function stemming from context_ui.admin.js.

Steps to reproduce

I experienced this while attempting to add a block to a context (e.g. /admin/structure/context/context_name).

Proposed resolution

Update JS file to handle once properly.

🐛 Bug report
Status

Closed: duplicate

Version

5.0

Component

Code

Created by

🇺🇸United States smeechos

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @smeechos
  • @smeechos opened merge request.
  • Status changed to Needs review about 1 year ago
  • 🇺🇸United States smeechos

    Created fork and MR w/ changes.

  • 🇨🇷Costa Rica MaxMendez

    Tested the pr and seems that requires changes on the original logic since new once library does not return the element selected.

    Here my initial approach, in the future i think jquery dependency should be remove using vanilla js, but it could be in other issue.

  • 🇮🇳India MukhtarM

    Hi @MaxMendez/ @smeechos I could not reproduce this issue on local using D10.1.1 and PHP8.2. I installed the context module and added a custom block (Don't know any step missed here). But afaik the issue is because of JQuery once (Once has been added to the core). may be its handled in Drupal core itself. Can you elaborate more on the step you added the block to context?

  • 🇨🇷Costa Rica MaxMendez

    Hi @MukhtarM

    My first observation was wrong because the once library returns elements, but as native selector not jQuery compatible, so .attr is not available o line 21.

    I applied MR 34 using D10.1.2, PHP8.2 and 5.0.0-rc1, add a block using the filter in the process and this is the result:


    Rethinking in the problem i simplified the patch to fix the problem and maintaining the original logic.

  • 🇮🇳India MukhtarM

    ok thanks @MaxMendez , i will review this

  • Status changed to RTBC 8 months ago
  • 🇧🇪Belgium RandalV

    I am also getting this issue.
    The original PR seems to work for me, altho I'm not sure on how complete it is.. I'll leave that up to the maintainer.

    I would however like to see this committed somewhat soon, because it is disruptive during the sitebuilding stage of a project.

  • 🇪🇸Spain Eduardo Morales Alberti Spain, 🇪🇺

    RTBC!

  • Hi all, any progress on this?
    This is still an issue as of 10.1.6 I've tested the above patch and it fixes the issue for us.

  • Status changed to Closed: duplicate about 2 months ago
  • 🇺🇸United States amanire

    I don't understand the comment in #6. I see the ' $input.attr is not a function' error after applying the MR!34 patch. The patch in https://www.drupal.org/project/context/issues/3374119 🐛 Search is broken when placing block RTBC resolves the issue for me.

Production build 0.69.0 2024