Skip to content

Instantly share code, notes, and snippets.

@ivanweiler
Last active May 25, 2022 12:14
Show Gist options
  • Save ivanweiler/fc2ab698e1f5ac0844424f8269599c35 to your computer and use it in GitHub Desktop.
Save ivanweiler/fc2ab698e1f5ac0844424f8269599c35 to your computer and use it in GitHub Desktop.

Select component in inspector and dump (in FF for example):

inspect(require('ko').contextFor($0));
inspect(require('ko').dataFor($0));

Get component from registry:

require('uiRegistry').get('componenet.name.in.layout')

Enable Ui component logger (not very usefull):

require('Magento_Ui/js/lib/core/storage/local').set('CONSOLE_LOGGER',5); 

Other

<pre data-bind="text: ko.toJSON($data, null, 2)"></pre>

<input data-bind="blah: console.log($data), value: description" />

https://stackoverflow.com/questions/9261296/how-to-debug-template-binding-errors-for-knockoutjs/16242988#16242988

ko.bindingHandlers.debug = 
{
    init: function(element, valueAccessor) 
    {
        console.log( 'Knockoutbinding:' );
        console.log( element );
        console.log( ko.toJS(valueAccessor()) );
    }
};

than simply use it likes this:

<ul data-bind="debug: $data">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment