themes – Load elements without reload page

At the outset, I apologize if this is a trivial question, but I have no idea what exactly I’m looking for.
I have page with categories like this
category list

My goal is when I click on category, page will not reload but will show me elements which are assigned to this category. Each category have one or more elements.
Someone can tell me what am I need. Example will be awesome!

Best Regards,
Bartek

libgdx – How can I avoid assets reload if an Android activity is re-created?

I’ve put my libGDX view inside a bigger Android layout. When the user rotates the screen, a new layout specific for the orientation is drawn, for this reason, the activity is rebuilt from scratch forcing the libGDX view to reload all assets.

I tried to store these assets in a static variable, but on the second time I create the libGDX view, they are not rendered correctly (it looks like textures are not loaded and everything is transparent).

How can I avoid reloading heavy assets (models and textures)?

mariadb – service mysql reload results ‘Access denied’, but service mysql start works

Using Debian 10.10.

I have a MySQL problem.

service mysql reload 

results ‘Access denied’

service mysql start

executes correctly.

All databases are working correctly after starting mysql. Strange, that reloading results access denied error.

Connecting to mysql with

mysql -p -u root -h localhost

connects successfully.

Only mysqladmin has problems:

mysqladmin start
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

mysqladmin reload
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'

Any idea what is the problem with mysqladmin?
Maybe some permission problem?

20.04 – How can I reload bashrc in a script and not failing?

I have written a script where it downloads anaconda3 and some other dependencies and then following the installation of anaconda3, couple of python modules are installed using pip3.
The issue is, my source ~/.bashrc doesn’t seem to work, and thus pip3s are not recognized. If I use exec bash, the remaining instructions after this command are not executed.
What should I do ?
This is my script by the way :

#!/bin/bash

## Bash script for setting up a PX4 development environment on Ubuntu LTS (16.04 and above).
## It can be used for installing simulators (only) or for installing the preconditions for Snapdragon Flight or Raspberry Pi.
##
## Installs:
## - Common dependencies and tools for all targets (including: Ninja build system, latest versions of cmake, git, anaconda3, pyulog)
## - jMAVSim simulator dependencies
## - PX4/Firmware source (to ~/src/Firmware/)

# Preventing sudo timeout https://serverfault.com/a/833888
trap "exit" INT TERM; trap "kill 0" EXIT; sudo -v || exit $?; sleep 1; while true; do sleep 60; sudo -nv; done 2>/dev/null &

# Ubuntu Config
echo "Remove modemmanager"
sudo apt-get remove modemmanager -y
echo "Add user to dialout group for serial port access (reboot required)"
sudo usermod -a -G dialout $USER

# Update CMake and Git
# Installing latest version of cmake (ref https://askubuntu.com/questions/355565/#865294 )
echo "Installing latest version of CMake"
sudo apt update && 
sudo apt install -y software-properties-common lsb-release && 
sudo apt clean all
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null
sudo apt-add-repository "deb https://apt.kitware.com/ubuntu/ $(lsb_release -cs) main"
sudo apt update
sudo apt install kitware-archive-keyring
sudo rm /etc/apt/trusted.gpg.d/kitware.gpg
sudo apt update
sudo apt install cmake

# Installing the latest version of git
echo "Installing the latest version of git"
sudo add-apt-repository -y ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git -y

# Install anaconda3
type conda >/dev/null 2>&1 || { echo >&2 "Installing anaconda3 (python 3.8.8)"; wget https://repo.anaconda.com/archive/Anaconda3-2021.05-Linux-x86_64.sh; bash ./Anaconda3-2021.05-Linux-x86_64.sh;}

source ~/.bashrc
. ~/.bashrc

# Common dependencies
echo "Installing common dependencies"
sudo apt-get update -y
sudo apt-get install git zip cmake build-essential genromfs ninja-build exiftool astyle -y
# make sure xxd is installed, dedicated xxd package since Ubuntu 18.04 but was squashed into vim-common before
which xxd || sudo apt install xxd -y || sudo apt-get install vim-common --no-install-recommends -y
# Required python packages
pip3 install argparse empy toml numpy
pip3 install pandas jinja2 pyserial pyyaml
pip3 install pyulog

# jMAVSim simulator dependencies
echo "Installing jMAVSim simulator dependencies"
sudo apt-get install ant openjdk-8-jdk openjdk-8-jre -y

reload page when going back in browser

is there any way to refresh the browser page when backtracking with javascript: window.history.go (-1);?

there is the option to use document.referrer; but I can only go back one page. yes, I must go back 2 or 3 pages I can’t get it to work.

I wanted to know if there is a possibility to use some function so that when you go back the page is refreshed.

Greetings.

plugins – Why do I need to reload the page for WordPress to see the new custom field added with jQuery

I added custom meta boxes and dynamically add an image loader button to it. The first image uploader works fine, it is generated by php. But, if I add a new row with an image loader button, then clicking on the button does not open the image loader, but the page is reloaded, at the same time the added new row is saved after refreshing the page and now if I click on the button, the image loader will open and everything will be OK.

This is how it looks in the admin area
enter image description here

Here is a function that adds a new row with a new image loader button. Found in the function.php file :

<script>
var addRow = function () {
    var rowCount = jQuery('#my tr').length;
    var w = "<?php echo $w; ?>";
    var h = "<?php echo $h; ?>";
    var def = "<?php echo $default; ?>";
    var def_id = 614;
    var title = "<?php echo $title; ?>";
    var upload_set_img = "<?php echo $upload_set_img; ?>";
    var html = "http://wordpress.stackexchange.com/";
        html +=  '<tr id="my-row'+rowCount+"http://wordpress.stackexchange.com/"><td><img data-src="https://wordpress.stackexchange.com/" + def + "http://wordpress.stackexchange.com/" src="https://wordpress.stackexchange.com/" + def + "http://wordpress.stackexchange.com/" width="http://wordpress.stackexchange.com/" + w + 'px" height="http://wordpress.stackexchange.com/" + h + 'px" />';
        html += '<div>';
        html += '<input type="hidden" name="my('+upload_set_img+')()" id="http://wordpress.stackexchange.com/"+ upload_set_img +rowCount+"http://wordpress.stackexchange.com/" value="http://wordpress.stackexchange.com/"+def_id+"http://wordpress.stackexchange.com/" />';
        html += '<button type="submit" class="upload_image_button button">Upload</button>';
        html += '<button type="submit" class="remove_image_button button">×</button>';
        html += '</div></td>';
        jQuery('#my tbody').append(html);
}
</script>

I suspect that WordPress is caching something during page load, and when the page is loaded and I added html using jQuery, it does not see this data, so it does not open the image loader in the newly added row.
But I’m not sure if this is the case and don’t know how to fix it. Someone could suggest how to solve this problem?

magento2 – How to reload Gallery image when Setting default option Product?

My point is when Go to the Product page (configurable Product), the product will load the first option automatically.
When trying to do it I had trouble loading new image for the first option and I found that the gallery has not loaded in first time. Could anybody help me to check this function?

In this file Magento_ConfigurableProduct/web/js/configurable.js

commerce – Reload Add to Cart form – Ajax issue

I am using this Add to Cart Ajax module to enable ajax on all AddToCart buttons. This works and makes all addToCart buttons use Ajax when adding a product.

The issue is, if you are on a product page that has variations, as you select and add variations, they should accumelate in the cart, as to be expected. But they don’t. What’s happening is the last added item always replaces the previous added item in the cart.

I think this happens because the page does not refresh while you change and add variations, it all happens with Ajax. Maybe the add to cart form needs to be reloaded/re-created on every addToCart (Which i think is happening anyway!!).

I can subscribe to the addToCart event but…

How do I go about re-creating the addtocart form so that the next time I click “Add to Cart” it won’t replace the previous added product, but add a new product to the cart?

Or do you think there is another explanation to this problem?

Drupal 9.1.10
Commerce 8.x-2.24
Commerce AddToCart Ajax 8.x-1.0

css – Hot reload with bundled assets are not being loaded/auto refresh in browser

I am trying to hot reload with my project’s bundled assets, but hot reload is not executing the browser refreshes when I make changes to any of my files.

I am looking at the F12 browser console, but nothing is being executed or loading, its just blank.

functions.php

function workshop_01_theme() {
    wp_enqueue_script('workshop_01-js', get_theme_file_uri('/bundled-assets/scripts.bedc8565a6cb22e37037.js'), NULL, '1.0', true);
    wp_enqueue_style('worskshop_01-style', get_theme_file_uri('/bundled-assets/styles.bedc8565a6cb22e37037.css'));
}
add_action('wp_enqueue_scripts', 'workshop_01_theme');

enter image description here

package.json

{
  "name": "workshop_01",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "dev": "npm-run-all -p devFast buildWatch",
    "devFast": "webpack serve",
    "buildWatch": "webpack --watch",
    "build": "webpack",
    "test": "echo "Error: no test specified" && exit 1"
  },
  "keywords": (),
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@babel/core": "^7.14.5",
    "@babel/preset-env": "^7.14.5",
    "@babel/preset-react": "^7.14.5",
    "@glidejs/glide": "^3.4.1",
    "autoprefixer": "^10.2.6",
    "axios": "^0.21.1",
    "babel-loader": "^8.2.2",
    "clean-webpack-plugin": "^4.0.0-alpha.0",
    "css-loader": "^5.2.6",
    "cssnano": "^5.0.6",
    "fs-extra": "^10.0.0",
    "jquery": "^3.6.0",
    "mini-css-extract-plugin": "^1.6.0",
    "normalize.css": "^8.0.1",
    "npm-run-all": "^4.1.5",
    "postcss-color-function": "^4.1.0",
    "postcss-hexrgba": "^2.0.1",
    "postcss-import": "^14.0.2",
    "postcss-loader": "^6.1.0",
    "postcss-mixins": "^8.1.0",
    "postcss-nested": "^5.0.5",
    "postcss-simple-vars": "^6.0.3",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "style-loader": "^2.0.0",
    "webpack": "^5.38.1",
    "webpack-cli": "^4.7.2",
    "webpack-dev-server": "^3.11.2",
    "webpack-manifest-plugin": "^3.1.1"
  }
}

scripts.js

import "../css/styles.css"

// Allow new JS and CSS to load in browser without a traditional page refresh
if (module.hot) {
  module.hot.accept()
}

webpack.config.js

const currentTask = process.env.npm_lifecycle_event
const path = require("path")
const MiniCssExtractPlugin = require("mini-css-extract-plugin")
const { CleanWebpackPlugin } = require("clean-webpack-plugin")
const { WebpackManifestPlugin } = require("webpack-manifest-plugin")
const fse = require("fs-extra")

const postCSSPlugins = (require("postcss-import"), require("postcss-mixins"), require("postcss-simple-vars"), require("postcss-nested"), require("postcss-hexrgba"), require("postcss-color-function"), require("autoprefixer"))

class RunAfterCompile {
  apply(compiler) {
    compiler.hooks.done.tap("Update functions.php", function () {
      // update functions php here
      const manifest = fse.readJsonSync("./bundled-assets/manifest.json")

      fse.readFile("./functions.php", "utf8", function (err, data) {
        if (err) {
          console.log(err)
        }

        const scriptsRegEx = new RegExp("/bundled-assets/scripts.+?'", "g")
        const vendorsRegEx = new RegExp("/bundled-assets/vendors.+?'", "g")
        const cssRegEx = new RegExp("/bundled-assets/styles.+?'", "g")

        let result = data.replace(scriptsRegEx, `/bundled-assets/${manifest("scripts.js")}'`).replace(vendorsRegEx, `/bundled-assets/${manifest("vendors~scripts.js")}'`).replace(cssRegEx, `/bundled-assets/${manifest("scripts.css")}'`)

        fse.writeFile("./functions.php", result, "utf8", function (err) {
          if (err) return console.log(err)
        })
      })
    })
  }
}

let cssConfig = {
  test: /.css$/i,
  use: ("css-loader?url=false", { loader: "postcss-loader", options: { postcssOptions :{ plugins: postCSSPlugins } }})
}

let config = {
  entry: {
    scripts: "./js/scripts.js"
  },
  plugins: (),
  module: {
    rules: (
      cssConfig,
      {
        test: /.js$/,
        exclude: /(node_modules)/,
        use: {
          loader: "babel-loader",
          options: {
            presets: ("@babel/preset-react", ("@babel/preset-env", { targets: { node: "12" } }))
          }
        }
      }
    )
  }
}

if (currentTask == "devFast") {
  config.devtool = "source-map"
  cssConfig.use.unshift("style-loader")
  config.output = {
    filename: "bundled.js",
    publicPath: "http://localhost:3000/"
  }
  config.devServer = {
    before: function (app, server) {
      // server._watch(("./**/*.php", "./**/*.js"))
      server._watch(("./**/*.php", "!./functions.php"))
    },
    public: "http://localhost:3000",
    publicPath: "http://localhost:3000/",
    disableHostCheck: true,
    contentBase: path.join(__dirname),
    contentBasePublicPath: "http://localhost:3000/",
    hot: true,
    port: 3000,
    headers: {
      "Access-Control-Allow-Origin": "*"
    }
  }
  config.mode = "development"
}

if (currentTask == "build" || currentTask == "buildWatch") {
  cssConfig.use.unshift(MiniCssExtractPlugin.loader)
  postCSSPlugins.push(require("cssnano"))
  config.output = {
    publicPath: "/wp-content/themes/workshop_01/bundled-assets/",
    filename: "(name).(chunkhash).js",
    chunkFilename: "(name).(chunkhash).js",
    path: path.resolve(__dirname, "bundled-assets")
  }
  config.mode = "production"
  config.optimization = {
    splitChunks: { chunks: "all" }
  }
  config.plugins.push(new CleanWebpackPlugin(), new MiniCssExtractPlugin({ filename: "styles.(chunkhash).css" }), new WebpackManifestPlugin({ publicPath: "" }), new RunAfterCompile())
}

module.exports = config

my webpack config file may be the issue, but I dont know what I should be doing to make hot reload work for my project here…

Debugging a page reload problem

I’ve got a page that does some fun stuff with data collection and outputs to a pdf. The data is stored in our database and is retrieved as json.

This works as expected for 99% of the forms we’ve created but one user has a problem where the page just reloads continuously.

If I step through the code I can see everything working just fine even for my two problem forms. I have a ton of console.log() turned on and all output as expected. Except that the page reloads.
SEMrush

I’ve got a pause on event listener for “DOMWindow.beforeunload” set and it stops there, sometimes, but the callstack just shows a jquery handler that also kicks in.

Because it doesn’t happen for every dataset I load I’d expect the problem to be in the data but then I’d also expect the unload to be triggered by something it doesn’t like in the code and for that to show in the callstack.

Any hints on how to debug this?