LearnNewsExamplesServices
Frontmatter
id6651
titlebutton.Base: onClick() => bind handler if string
stateClosed
labels
enhancement
assignees[]
createdAtApr 15, 2025, 4:32 PM
updatedAtApr 15, 2025, 9:39 PM
githubUrlhttps://github.com/neomjs/neo/issues/6651
authortobiu
commentsCount2
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtApr 15, 2025, 9:29 PM

button.Base: onClick() => bind handler if string

Closed v9.0.0 enhancement
tobiu
tobiu commented on Apr 15, 2025, 4:32 PM
  • view controller should not need to parse for button handlers, but it should be get driven
  • => the first click on a button when the handler is a string should resolve and bind it
  • util.Function: resolveCallback() needs to honor view controllers
  • core.Observable needs a new bindCallback() method
tobiu added the enhancement label on Apr 15, 2025, 4:32 PM
tobiu referenced in commit a32abb0 - "button.Base: onClick() => bind handler if string #6651" on Apr 15, 2025, 4:32 PM
gplanansky
gplanansky Apr 15, 2025, 9:01 PM

@tobiu https://github.com/neomjs/neo/blob/a32abb086068ef9caf0b0a2a502889b6c47f6d94/src/button/Base.mjs#L502

If me.handler is undefined, e.g.: neo/examples/stateProvider/table click to sort the Firstname column, this yields error message:

Uncaught TypeError: me.handler is not a function
    at Button.onClick (Base.mjs:503:12)

changing:
me.handler(data);
to:
me.handler && me.handler(data);

makes that error message go away.

The neo/examples/table/nestedRecordfields app shows the same behavior, and also, for clicks to the Edit buttons, invokes a handler that does exist.

tobiu
tobiu Apr 15, 2025, 9:28 PM

Good catch George,

handlers need to stay optional. This only affects the dev branch => for the next release I need to adjust listeners & domListeners in a similar get driven way.

I will create a follow-up ticket for header buttons using onClick() directly.

tobiu referenced in commit 1b907d4 - "#6651 keeping handlers optional" on Apr 15, 2025, 9:28 PM
tobiu closed this issue on Apr 15, 2025, 9:29 PM