diff --git a/panel/param.py b/panel/param.py index 36915a1505..c9ebc626bb 100644 --- a/panel/param.py +++ b/panel/param.py @@ -532,6 +532,23 @@ def widget_type(cls, pobj): return cls._mapping[t](pobj) return cls._mapping[t] + def select(self, selector=None): + """ + Iterates over the Viewable and any potential children in the + applying the Selector. + + Arguments + --------- + selector: type or callable or None + The selector allows selecting a subset of Viewables by + declaring a type or callable function to filter by. + + Returns + ------- + viewables: list(Viewable) + """ + return super().select(selector) + self.layout.select(selector) + def get_root(self, doc=None, comm=None): """ Returns the root model and applies pre-processing hooks diff --git a/panel/tests/test_param.py b/panel/tests/test_param.py index dd531f631b..e647c7571a 100644 --- a/panel/tests/test_param.py +++ b/panel/tests/test_param.py @@ -832,6 +832,24 @@ class Test(param.Parameterized): assert len(model.tabs) == 1 +def test_param_js_callbacks(document, comm): + class JsButton(param.Parameterized): + param_btn = param.Action(lambda self: print('Action Python Response'), label='Action') + + param_button = Param(JsButton()) + code = "console.log('Action button clicked')" + param_button[1].js_on_click(code=code) + + model = param_button.get_root(document, comm=comm) + + button = model.children[1] + assert len(button.js_event_callbacks) == 1 + callbacks = button.js_event_callbacks + assert 'button_click' in callbacks + assert len(callbacks['button_click']) == 1 + assert code in callbacks['button_click'][0].code + + class View(param.Parameterized): a = param.Integer(default=0)