Share via

main.js:292 Uncaught TypeError: Cannot read properties of undefined (reading 'display')

Volk Volk 551 Reputation points
2023-10-13T18:52:40.8233333+00:00

Hi!

I have a main page on which the mouse wheel scroll works in main.js.

<script src="~/js/main.js"></script>

// Wheel event
$body.on('wheel', function (event) {

	var $theme_panel = $('#theme_panel');

	if ($theme_panel) {
		var $style = $theme_panel.style.display;
		if ($style != 'none') {
			return;
		}							
	}

	...
}

There is also a pop-up window that appears when you click on the image on the main page.

I need to turn off scrolling with the mouse wheel on the main page as soon as the pop-up window appears and turn on scrolling again when the pop-up window closes.

The pop-up window has id="theme_panel":

<ul class="posts" id="theme_panel">

I just need to somehow figure out when the pop-up window appeared on stage and when it disappeared.

I thought I needed to check for display != 'none' (or maybe something else), but at startup I keep getting an error in the line var $style = $theme_panel.style.display;:

main.js:292 Uncaught TypeError: Cannot read properties of undefined (reading 'display')

Tell me, what am I doing wrong?

Thanks!

Microsoft 365 and Office | Development | Office JavaScript API
0 comments No comments

1 answer

Sort by: Most helpful
  1. Volk Volk 551 Reputation points
    2023-10-17T13:02:10.24+00:00

    Sorry, it's my fault. The question is incorrect. I was helped to solve it on stackoverflow.com . The question is closed.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.