Liam Fell
Liam Fell

Reputation: 1320

jQuery, performing a function on page load

I'm building a finance calculator with jQuery which is working well. The calculator uses jQuery sliders. I have the following function which is called when a slider is activated.

However I need to replicate this so the same actions are called on page load, could anyone suggest how I might achieve this?

jQuery(document).ready(function($) {
    $("#slider-deposit").slider({
        value: 100,
        min: <?php echo json_encode($minDeposit); ?>,
        max: <?php echo json_encode($maxDeposit); ?>,
        step: 1,
        slide: function(event, ui) {
            $("#amount-deposit").val(Number(ui.value).toFixed(2));
            totalPayableFunc();
            monthlyPaymentsFunc();
        }
    });
    $("#amount-deposit").val("" + $("#slider-deposit").slider("value"));
});

Upvotes: 0

Views: 67

Answers (1)

Steve Harris
Steve Harris

Reputation: 5109

Is it this?

jQuery(document).ready(function($) {
    $("#slider-deposit").slider({
        value: 100,
        min: <?php echo json_encode($minDeposit); ?>,
        max: <?php echo json_encode($maxDeposit); ?>,
        step: 1,
        slide: function(event, ui) {
            $("#amount-deposit").val(Number(ui.value).toFixed(2));
            totalPayableFunc();
            monthlyPaymentsFunc();
        }
    });
    $("#amount-deposit").val("" + $("#slider-deposit").slider("value"));
    totalPayableFunc();
    monthlyPaymentsFunc();
});

Upvotes: 1

Related Questions