kabue-charles

Using Select2.js jQuery plugin

Lately, I have been on a project that required a heavy use of HTML select. I choose select2 after a period of comparison which other plugins like choose.js and selectize.js. it was very easy to get along, thanks to the almost enough documentation. i am writing this post to answer my own question which I asked at stackoverflow, since I never got even a single relevant response. Its really scaring how some stackoverflow boys want to cause trouble when you mean no harm. I mean, if you see someone asking a SLIGHTLY AMBIGUOUS question, it means that most likely, they only have the idea of what is to be done. Sometimes you don’t even know what to Google, so you feel inclined to ask a question so at least you get your search terms right, or should stackExchange have another site called “search-terms”??

Anyway, here was my question…

Autofilling inputs and selects with select2

and here is my answer…

<form style="width: 350px;" id="" class="navbar-form form" role="form" data-bind="">
<dl class="dl-horizontal">
<dt>President</dt>
<dd><select data-placeholder='President' id="president" class="select11" style="width: 300px;">
<option></option>
<option value="AK">Mickel</option>
<option value="HI">James</option>
<option value="CA">Sandney</option>
</select>
</dd>
<dd>
<input id="runningMate" placeholder="running mate" class="form-control" type="" name="" style="width: 300px;" disabled>
</dd>
</dl>

<dl class=”dl-horizontal”>
<dt>Secretary General</dt>
<dd><select data-placeholder=’Secretary General’ class=”select11″ style=”width: 300px;”>
<option></option>
<option value=”AK”>Alaska</option>
<option value=”HI”>Hawaii</option>
<option value=”CA”>California</option>
<option value=”NV”>Nevada</option>
<option value=”OR”>Oregon</option>
</select>
</dd>
</dl>

<dl class=”dl-horizontal”>
<dt>Financial Controller</dt>
<dd><select data-placeholder=’Financial Controller’ class=”select11″ style=”width: 300px;”>
<option></option>
<option value=”AK”>Alaska</option>
<option value=”HI”>Hawaii</option>
<option value=”CA”>California</option>
<option value=”NV”>Nevada</option>
<option value=”OR”>Oregon</option>
</select>
</dd>
</dl>

<dl class=”dl-horizontal”>
<dt>Faculty representative</dt>
<dd><select data-placeholder=’Choose Faculty’ id=”faculty” class=”select11″ style=”width: 300px;”>
<option></option>
<option value=”fist”>fist</option>
<option value=”commerce”>commerce</option>
<option value=”spas”>spas</option>
</select>
</dd>
<dd><select data-placeholder=’Faculty representative’ id=’representative’ class=”select11″ style=”width: 300px;”>
<option></option>
</select>
</dd>
</dl>
</form>

and here is the script that is doing the magic…
<script>
$(function(){
$('#president').select2({
allowClear: true
})
.on("select2-selecting", function(e) {
if (e.choice.text == "Mickel"){ $('#runningMate').val('Mercy is ' + e.choice.text + "'s Running Mate"); }
else if (e.choice.text == "James"){ $('#runningMate').val('Mukami is ' + e.choice.text + "'s Running Mate"); }
else if (e.choice.text == "Sandney"){ $('#runningMate').val('Moses is ' + e.choice.text + "'s Running Mate"); }
})

$(‘#representative’).select2({
allowClear: true
});

$(‘#faculty’).select2({
allowClear: true
})
.on(“select2-open”, function() {
fist=new Array(“jamo”,”sam”,”kaka”,”jane”);
commerce=new Array(‘chalo’,’mark’,’timo’);
spas=new Array(‘ali’,’Elke’,’Fred’,’Bobby’,’Frits’);

$(‘#faculty’).change(function(){ populateSelect(); });
function populateSelect(){
var representative = $(‘#faculty’).val();
$(‘#representative’).select2(“data”,””);
$(‘#representative’).html(‘<option></option>’);

eval(representative).forEach(function(t) {
//$(‘#representative’).select2(“val”:””);
$(‘#representative’).append(‘<option>’+t+'</option>’);
});
}
})
});
</script>

and this is what i got…

select1

select2

God doesn’t live, He exists…but Humans do

I will say this again so it doesn’t seem like I gave the wrong title, “GOD DOESN’T LIVE, HE EXISTS!” What do I mean? What is the difference between living and existing anyway? Living revolves and involves a purpose, but God doesn’t have a purpose for living, in fact, He doesn’t require to live (or have a purpose), He just or plainly exits.

Human beings live because, according to the bible, we are supposed to please He from whom we are! But then again, how could God be pleased by something that is solely dependent on His commands? Then it would mean that there is a likelihood He is sometimes not pleased by His self, which might explain His reason of giving instructions that are not pleasing to you Himself… what all those lines above are trying to explain is that there was no reasonable reason for God to control us, what we do, what we ask, how or what we think, what we see things, what we imagine, or how we speak or hate and love! He wanted to be served by a god like Himself. We are gods. Go read Genesis 1:26, it says;

 26 Then God said, “Let Us make man in Our image, according to Our likeness; let them have dominion over the fish of the sea, over the birds of the air, and over the cattle, over all[a] the earth and over every creeping thing that creeps on the earth.”

Each and every one of us is a god! That is why we are able to tame every animal, plant, even people and sometimes creation. That’s why we are all free thinkers, well, unless you are locked to the cages of un-civilization, culture or religion. He wanted to be served by us free willingly.

Well thank you for pointing at me, “Look at this fool.” How many fingers of you are pointing at your chest as you point at me? Three! Three fingers telling you to be less stubborn and at least go research about this free revelation, that is if you will not be willing to be accept it.

But in general, in order to co-exist with each other, we all have to be at one time or the other be tamed, so that we don’t misbehave. That’s why we have the constitution, personal principles, freemasons, including culture, beliefs, faith, and religion.

LOST AND FOUND TREASURE

WP_20150108_002

Long time ago (like 10 years back from today, 1/8/2015), I found a very small book in our home. I choose to take it, and I opted to understand what it contained. It had no cover page, and most of the last pages were not there, besides the remaining ones being torn. The remaining pages had stood the test of time and the wrath of hungry rodents.

The book had content related to the journey of Christian salvation. Now am in my final year in campus and after a very long time of searching its presence online, I succeeded in failing to find it. So I have decided to write it, letter by letter, thanks to my 2nd New Year (2015) resolution of writing at least three posts per week.

Here at school, there are bible study sessions with very nice guide books, but none is close to how compelling and convincing this little book I found when I was in primary is.

Here is the 1st page of the torn treasure. I don’t know why, but I always felt that the book can help someone…

WP_20150108_004

The contents of this book include:


 

i. Jesus invites us to follow Him
ii. Why we need to follow Jesus
iii. How can we follow Jesus?
iv. Followers of Jesus must repent
v. Followers of Jesus must be born again
vi. Followers of Jesus must be consecrated
vii. Followers of Jesus must be filled with the Holy Spirit
viii. Followers of Jesus overcome sin
ix. Followers of Jesus love their Bibles
x. Followers of Jesus love to pray
xi. Followers of Jesus must work for Him
xii. Followers of Jesus must be ready for His return
xiii. Questions


I will be writing one post per week on each of the above contents. If I fail to write, my believe is you will be a little patient with me because I have the final campus project waiting for me to complete, besides helping my friends do theirs…

Anger

There once was a little boy who had a bad temper. His father gave him a bag of nails and told him that every time he lost his temper, he must hammer a nail into the back of the fence. The first day the boy had driven 37 nails into the fence. Over the next few weeks, as he learned to control his anger, the number of nails hammered daily gradually dwindled down. He discovered it was easier to hold his temper than to drive those nails into the fence.

Finally the day came when the boy didn’t lose his temper at all. He told his father about it and the father suggested that the boy now pull out one nail for each day that he was able to hold his temper. The days passed and the young boy was finally able to tell his father that all the nails were gone.

The father took his son by the hand and led him to the fence. He said, “You have done well, my son, but look at the holes in the fence. The fence will never be the same. When you say things in anger, they leave a scar just like this one. You can put a knife in a man and draw it out. It won’t matter how many times you say I’m sorry, the wound is still there.”

A verbal wound is as bad as a physical one. Friends are a very rare jewel, indeed. They make you smile and encourage you to succeed. They lend an ear, they share a word of praise, and they always want to open their hearts to us.

Source

Will my fingers grow back?

While a man was polishing his new car, his 4 yr old son picked up a stone and scratched lines on the side of the car. In anger, the man took the child’s hand and hit it many times; not realizing he was using a wrench.At the hospital, the child lost all his fingers due to multiple fractures.When the child saw his father….. with painful eyes he asked, ‘Dad when will my fingers grow back?’The man was so hurt and speechless; he went back to his car and kicked it a lot of times. Devastated by his own actions…. sitting in front of that car he looked at the scratches; the child had written ‘LOVE YOU DAD’.The next day that man committed suicide…. Anger and Love have no limits; choose the latter to have a beautiful, lovely life….. Things are to be used and people are to be loved, But the problem in today’s world is that, People are used and things are loved…During the day, be careful to keep this thought in mind: Things are to be used, but People are to be loved … Be yourself…. This is the only day we HAVE. Have a nice day Watch your thoughts; they become words. Watch your words; they become actions.Watch your actions; they become habits. Watch your habits they become character; Watch your character; it becomes your destiny.


Source

The Chase

We are all in a race, chasing something…this thing that we’re chasing keeps us focused, it gives us hope, it makes us believe, it pushes us to trust, or this thing just makes us who we are. There are things that we chase alone…like revenge, some love, some chase adventure, others are always chasing “nothing”…which in this sense “NOTHING” is an substance. But there are things that we all chase together. Things that make animals, plants, humans, and bacteria’s EQUAL. Things like food, time, and evolution.
Someone caused an accident because they were in hurry – TIME. You wake up early so you don’t get fired at work – FOOD. You changed you phone because the one you had looked outdated – EVOLUTION. It doesn’t matter who you are, or how honorable you are, you will always find that you work to feed yourself or someone else… HIV virus is advancing each moment we approach to find it’s cure… And if we’ll ever get even close to cure it, we will be distracted enough so that another stronger species will have matured. Ebora, Cancer  and other really poisonous diseases are all caused by a very well known and understood organism, but why can’t we find a way to kill it? Because it evolves. Try eating your favourite meal three times a day for just one month and you’ll realise how disgusting it tastes…

&nbsp;

What if it’s true?

Before i say this, allow me to first say that am a Christian. A very born-again son of God. I have been baptized twice, one when I was a kid in the The Catholic Church, and when I was around 17 years in the Full Gospel Churches of Kenya.
I believe in Heaven as all other Christians do, but what if it’s really true what Hindus say that when we die, we return back as animals?
If you have the ability to think INDEPENDENTLY, then you’ll agree with me that there is a possibility that Hindus are correct, because no one in the world is solid sure that what they believe is what is supposed to be true. Truth is just genuine sincerity plus a pure conscience! So any one can be true. Being true and being right is like two separate pages from two different books. There’s a chance that the books might be related, but it depends on a personal judgment.
My question is dead simple. What if its really true there is chance we’ll come back as animals after we die, would you like to be treated the way you treat the animals around you?

Knowledge is Power

God made the universe, made animal, made plants, and created the humans. He then made humans in charge of everything. He made human a god on earth. That is biblically true since during creation of Humans, God said, “Let Us create an image with our own likeness”. The likeness of God is being God, so we are gods…
Our intelligence helps us keep all other creatures under control. We don’t have to be as strong as elephants, or brave as lions, or fast as cheetahs… We are automatically in control of nature.
But there is something we can’t control even if we were given the means to. Its Evolution. Trying or even thinking to control Evolution is like being a cannibal, and starting to feed on your own body. There is a line separating what we know, what we can know, and what no one will ever know, like the details of life, soul, and spirit…
Any being with a slightly higher knowledge than humans on earth has us in control. The being can do whatever it wishes with us, all because we would never comprehend. Knowledge directly determines the level of control we have. That is why there are ranks at work to grade employees according to experience, and skills.

It is good

A King had a male servant who, in all circumstances, always said “It is good”.
One day, they went hunting and a wild animal attacked the king, the servant managed to kill the animal but couldn’t prevent his king from losing a finger. Furious and without showing gratitude, the King said; if God was good, I would not have been attacked and lost one finger.
The servant replied, “It is good”. Outraged by the response, the king ordered the arrest of his servant. While being taken to prison, he told the king again, “It is good”.
Another day, the king left alone for another hunt and was captured by savages who use human beings for sacrifice.
On the altar, the savages found out that the king didn’t have one finger in place, he was released because he was considered not “complete” to be offered to the gods. On his return to the palace, he ordered the release of his servant and said; My friend, God was really good to me. I was almost killed but for lack of a single finger, I was let go. But I have a question;
If God is so good, why did He allow me to put you in prison? His servant replied; “It is good because if you had not  put me in prison, I would have gone with you, and i would have been sacrificed, because I have no missing finger.
God is good, perfect and He is never wrong

And would you help me convince this man that God is Uniquely Perfect and that His design was 100% fit…