Search code examples
javascriptjquerydomdynamic-html

OnSubtreeModified add my function


I use pie.js (http://css3pie.com/) a library that allows me to have css3 on ie6+. I apply pie.js on document.ready :

 $(document).ready(function(){
        if (window.PIE) {
            $('.vexClass, #vexId').each(function(){
                PIE.attach(this);
            });
        }

    });

My problem is when the dom was modified the elements for which I have apply pie.js are not rendering well so I must load my function that apply pie.js to my elements when the dom is modified and only for section that was modified using OnSubtreeModified or another technique ... For example I have a panel that is displayed when dom was loaded, in that panel I have a button that is expanding another panel with buttons and other elements for which I want to apply pie.js, so for main panel all elements for which I have applied pie.js are rendered ok but the elements from expanded panel, pie.js is not applied :| So how can I inject that pie.js when dom is modified for expanded panel?

Thank's.


Solution

  • If you are using wicket the only way to do that is through Wicket.Ajax.registerPostCallHandler Add this in your project, every time when a ajax request is done your pie will be applied.

    window.document.ready = function() {
        Wicket.Ajax.registerPostCallHandler(pieStarter);
    }
    function pieStarter() {
    
        if (window.PIE) {
            go();
        }
    }
    function go() {
        $(''.vexClass, #vexId'').each(function() {
            PIE.attach(this);
        });
    }