A
A
ART42018-01-19 21:46:03
WordPress
ART4, 2018-01-19 21:46:03

Installing code on wordpress?

Hello, I'm in a situation and don't know what to do.
Wrote a calculator for the site. Purely in php, html, js, css. Locally it works fine.
Now I'm trying to embed in wordpress on the page half does not work.
I use Jquery 1.9.1 in the code, version 1.12.4 is on the site . If I use the 1.12.4
library, then my code throws an error:

function incrementRoomValue() {
    // Get current values
    var value = parseInt(document.getElementById('iptCountRoom').value, 10);
    var timeTotalApartmentMinute = parseInt(document.getElementById('iptTimeTotalApartmentMinute').value, 10);
    var nextTotalApartmentMinute = timeTotalApartmentMinute + timeAddtRoomMinute;
    // Check about max
    if (value < maxRoomsCount && nextTotalApartmentMinute <= maxSliderMinute) {
        // Increment
        value = incrementValue(value, maxRoomsCount);
        checkIncDecButtonRoom(value, minRoomsCount, maxRoomsCount);
        document.getElementById('iptCountRoom').value = value;
        // View
        document.getElementById('divRoomsCount').innerHTML = value.toString()
            + ' ' + getEnding(value, endingStrings.aRoomEndings);
        document.getElementById('spRoomsCount').innerHTML = value.toString() +
            ' ' + getEnding(value, endingStrings.aCalculateRoomEnding);
        document.getElementById('aIncBathroom').className = 'plus-room';
        // Calculation
        calculationApartment(true, timeAddtRoomMinute);
        checkTotalTime();
    }
}

This is where var nextTotalApartmentMinute = timeTotalApartmentMinute + timeAddtRoomMinute;
Error Uncaught ReferenceError: timeAddtRoomMinute is not defined

If I take it as I originally did on 1.9.1
, then
Uncaught ReferenceError: countRoom is not defined
    at HTMLDocument.<anonymous> 
    at c 
    at Object.fireWith [as resolveWith] 
    at Function.ready 
    at HTMLDocument.H

And it scolds my library. How to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan Hasanli, 2018-01-19
@azerphoenix

Have you tried deregistering the standard jquery in the theme's functions.php and adding your own version?
Something like this...

function register_myscripts() {
    
  wp_deregister_script('jquery');
  wp_register_script('jquery', get_template_directory_uri() .
    '/assets/js/jquery.js');
  wp_enqueue_script('jquery');
  
}

add_action('wp_enqueue_scripts', 'register_myscripts');

+ connect all external scripts via functions.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question