Knockout-Contrib / Knockout-Contrib/KoGrid
Using a method defined in the global context with a cell template that has a click binding
- Dominant language
- JavaScript
- Stars
- 277
- Forks
- 124
- PR merge metrics
- No merged PRs in 30d
Description
Not sure if this is the correct place but here goes. Have a cell template
cellTemplate: '<img data-bind="visible: !$parent.getProperty(\'IsEaSource\'), attr: {id: $parent.getProperty(\'HPD_MEMBER_TYPE\')}, click: function(data, event){$userViewModel.deleteMembership($parent.entity);}" class="gridDeleteColumn" src="../Images/koGrid/delete.png"/>'
It has a click knockout binding. When i try to run a function defined in the viewmodel and i access it using the $userViewModel the method is found and runs fine. However, if i try to simply run a function that was globally defined:
function(data, event){someGlobalFunction($parent.entity);
I keep getting an error when the click event fires saying that someGlobalFunction is not defined. What am i doing wrong?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by tracing the cellTemplate's Knockout click binding and compare how $userViewModel is resolved with how someGlobalFunction is looked up when the event fires. Reproduce the reported error with the shown template, then document or test the expected behavior for globally defined functions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100