Setup
I create an OO.ui.ButtonWidget in javascript and then display it using $( '#XXX' ).append( mybuttonwidget.$element ).
Lets say the id of this OO.ui.ButtonWidget is YYY.
What I'm trying to do
I would like to disable this button latter depending on another event, where I don't have access to the original object mybuttonwidget but can only fetch the node $('YYY').
Problem
I would like to use its methods. The following doesn't work:
$( '#YYY' ).setDisabled( true )
The problem is that what I am fetching with $ is not an OO.ui.ButtonWidget but just the node. I assume I either need to recover the object, reconstruct the object or do something similar to infuse() but with a node created in javascript and not in php.
Questions
Is there a way of infusing or doing the inverse of mybuttonwidget.$element? so that I can use .setDisabled or any other method of OO.ui.ButtonWidget. Looking at the class or parents and I don't see anyway of doing it
Is there an alternative way of doing this? I was thinking of creating a global but I may also need to do the same with a class of ooui objects where determining which one I need to access is not obvious