triggerHandler 'rightnow' not updating on page refresh

63 Views Asked by At

I'm no expert on jQuery and javascript but have achieved pretty much what I wanted. On https://wand-op-maat.nl you see a customizer at the top. When entering values in the fields below it the images and wall change. It was quiet a challenge to get this far but I'm having some problems on pageloads..

the values in the fields do not always update the image sizes, when you change a field it always works perfectly.

This is an example for one of the niches in the wall:

$("#nis1").bind('change load rightnow', function() {
        if ($(this).is(':checked')) {

            $("#nis1breedte, #inputnis1breedte").bind('change load paste keyup rightnow', function() {
                    var nis1breedte = ($( this ).val()) / 2;
                    $( "div.nis-1" ).width( nis1breedte + 'mm');
                }).triggerHandler("rightnow");  
            $("#nis1hoogte, #inputnis1hoogte").bind('change load paste keyup rightnow', function() {
                    var nis1hoogte = ($( this ).val()) / 2;
                    $( "div.nis-1" ).height( nis1hoogte + 'mm');
                }).triggerHandler("rightnow");  

            $("#nis1positielinks, #inputnis1positielinks").bind('change load paste keyup rightnow', function() {
                    var nis1positielinks = ($( this ).val()) / 2;

                    $( "div.nis-1" ).css( 'left', nis1positielinks + 'mm');
                }).triggerHandler("rightnow");  
            $("#nis1positieonder, #inputnis1positieonder").bind('change load paste keyup rightnow', function() {
                    var nis1positieonder = ($( this ).val()) / 2;

                    $( "div.nis-1" ).css( 'bottom', nis1positieonder + 'mm');
                }).triggerHandler("rightnow");  
        }
        }).triggerHandler("rightnow");

I hope someone is able to guide me in the right direction here.

If you have any tips for my jquery codes or the customizer I'm happy to hear them as well :-)

Regards,

Philippe

0

There are 0 best solutions below