Search code examples
javascriptjqueryjsonstringify

JSON panel onClick event triggering


I'm trying to use JSONpanel.js /example and docs can be found HERE, everything works fine but as default this plugin provide onClick event registration for JSON containing arrays or lists - this array is expanded only after event click. But is there some way how to trigger onClick event or register another type of event - I need to all expandable links to be expanded after page is loaded not only after click on it.

Exmple code where click event is registered:

ExpandablePair.prototype.createTagInnerMarkup = function(){
var $expander = $('<a class="expander" href="#">');
$expander.on('click', $.proxy(this.onKeyClick, this));  
var innerMarkup = Pair.prototype.createTagInnerMarkup.call(this);
$expander.append(innerMarkup);
return $expander; };

Many thanks for any advice!


Solution

  • $(document).ready(function(){
        $(".expander").click()
    })
    

    If i understand your issue correctly this should expand all those anchors by class. This should be done after the expand click event is registered.