Debugging jQuery Code for dummies

At least some of us might have learnt jQuery the hard way.

As it has been said for a long time, the best way to understand jquery or any other code is to read through code written by other people. jQuery is unique because it uses html and css flags to make things happen.

Debugging jQuery code is sometimes not easy, even with some experience. This is because, parts of html and JavaScript code are linked together by a id or a class.

Steps to debug jQuery


I will try and explain the steps by way of a html and jQuery code example below.

Find the trigger word


You see, buttons or links are created with id or class and the id and class names are then used to trigger activity.

In one part of the code, there will be something like




There are events that trigger an action. The event may be on an input field, a list box a submit button or something else; and the event may be a change in the field, a click on a field, a mouse over action, a mouse out action and other such events.


Locate the trigger word in the JavaScript/jQuery code


Elsewhere in the code, there will be something like 
$('body').on('click','.saverecord',function(){ some code here }
$('body').on('click','.editrecord',function(){ some code here }

If you analyze the above code, you will see that the trigger is a click on the class called save, which executes an anonymous function that is embedded within braces.

So, a search for the keyword "saverecord" in the code will help you locate the flow of the program.

If you do not know how a jQuery code is organized, here is a short primer which tells you the framework of a jQuery code.

The Secret to a Better Life

Is there any one thing, which if we do, we will have a better future?

I would say "Yes, there is".

BE STILL! Do nothing!

Essentially, we are all spiritual beings, who are here for a reason. We are given a chance to live life in a manner that benefits us and others.

As we see, each one of us experiences life differently, based on our past experiences, our past acts done out of anger, humility, love, greed and so on.

But, because of our limited knowledge of the universe and its workings, we are happy during good times and during bad times complain that God is being cruel to us for no fault of ours.

What we fail to realize is that whatever experiences that we are going through in our life, it is all the result of an accumulation of past activities; ours, our ancestors and our society. It has been called many names from ancient times, but for the sake of better understanding, we will call it Causal action.


The Buddha Story


You must have heard about this story about the Buddha. He used to go about the village everyday, seeking food from the residents. People used to give him food, while some desisted. But, there was one household, where the master of the house scolded him for begging for alms when he was hale and healthy. Why can't you go and do work? He rained the choicest abuses upon him. All the while, the Buddha maintained his silence. And, when the abuses stopped, he went on to the next household.

The next day, he went to the same households again and in this particular house, the master got even more angry and hurled more abuses seeing the Buddha again.

This happened every day for the next few days. The abuses became feebler as the days passed by, until one day, when this person asked the Buddha, "When I abuse you, you are not responding and talking back and not even trying to offer an answer. Are you not angry?". The answer the Buddha gave was "When you offer me something, it becomes mine, only when I take it from you. I have not accepted any of the abuses that you offered me during the past few days. They remain with you."

This is a profound incident, which should offer us some understanding of how the Universe works and how enlightened souls respond to stimuli.


The Secret of Life


There is another aspect to this which I would add here. The Buddha was shouted at by the householder, because of his past actions. At the time, the Buddha did the right thing of not responding to the householder, because that would mean that he is creating another "causal action", which would result in further responses on his life.

We are just looking at one single incident here. There may be umpteen such incidents that will happen in our entire life. When we stop reacting aggressively to all that is happening that is causing us distress in our life, we reduce the "accumulated causal action" from our debt and hence our later life would be better than it is right now.

So, there you are, with the most important secret to our life;

In short, BE STILL! DO NOT REACT AND TAKE LIFE AS IT COMES!

No, this does not mean that we do nothing. What it means is that we do all the things that we do everyday, while refraining from doing things that adversely affect others, while at the same time, not reacting to bad things that happen to us.

What has to happen, happens, will happen. We would do well not to turn the tiles again, to make it happen, again!!!

Here is a tidbit to go.

Our actions result in positive or negative impact on other beings around us. These will be recorded for and against us for the future. It is also called the spiritual bank balance, as opposed to our material bank balance. The material bank balance, we cannot carry forward to the next life. But, the spiritual bank balance, we can.

As an example, if you have made a billion in cash in your lifetime, donate half of it in the benefit of the society and nature. You would have then saved by instant transfer, for your next life.

Good luck to you all!

Btw, What is Luck anyway? Let us discuss that elsewhere.

Why is there so much suffering in the world


If God is real then why is there so much suffering?
How can there be a God who can allow all this atrocities to happen?

These are the kind of questions that arise in most minds, whether they follow any of the world's religions such as Christianity, Buddhism, Islam or other religions or atheism or neutral in their belief.

The philosophical answer to this is that it is the destructive actions of humans that caused it. Then, the reactions of humans to the ills happening to them perpetuates it.


The top executive is concerned with macro issues


The logical answer to this is that assuming there is a God, He is not coming down to help you out of a fix, in the same manner that President Obama or whoever is your head of state, is not going to come down to you and help you out of a fix.

The top person never addresses micro level problems; their focus is at the macro level.


We are responsible for our actions, nobody else


Next, whatever problems that we are in, are the result of our past actions. This is explained by the fact that we studied well in school, or excelled in a sport and are well placed in our life today. On the other hand, another set of students, wasted their time, watching movies, getting into bad habits and now are in a precarious position in their life. 

How is it that we can blame God for our actions? We get an interest from a bank only when we deposit money in the bank. We have to pay interest if we have taken a loan.


It is called Karma

Newton said, for every action, there is an equal and opposite reaction.

The same rule works for every action of ours, good or bad. Only that the results are manifold, not just in the ration of 1:1

For every good deed that you do, the benefits come to you many times over. Similarly, for all the bad deeds we have done, the punishments are going to be manifold too.


Why is the person doing bad deeds living a grand life?

The most repeated question against the existence of God is "If there is a God, then why are bad people not punished?". How do we know they are not punished? The fact remains that we are viewing life from a small key hole. We do not get the whole picture.

Let us again take the example of the bank deposit here. The deposit that we put in a bank accrues interest only after a specific time. 

All the bad deeds that we do are like an overdraft from a bank, you are allowed to draw so long as your deposits allow. And whatever you draw, you have to pay back.

Similarly, all the bad deeds that we do will begin to hurt us only after our deposit has become negative.

Man is now a symbol of destruction.

Man has forgot to live in harmony with the nature.

Man has forgot to live in tune with the system.

Man has become greedier in search of material possessions...

Once we stop or fail to reflect on our actions, suffering is invariably the end result.



Imagen 3: A New Era of AI Image Creation?

  Google has just unveiled Imagen 3, the latest iteration of their Gemini AI. They're making bold claims about enhanced image quality, ...

Most Popular

Copyrighted.com Registered & Protected DWYE-NHTO-NBNH-7FFM