Friday, September 12, 2014

Making jQuery and Boostrap 3 and "hide" class work together

One of the problems with using jQuery's show and hide methods is that they are not compatible with the provided Bootstrap css classes "show" and "hide".

What is the problem? Bootstrap's css class looks like this:



.hide {
  displaynone !important;
}

Those important styles are necessary on some elements to make the behavior as expected. However, jQuery doesn't overwrite them when setting css attributes with the built-in show/hide methods. The recommended way that I found is to manually use .addClass("hide") and .removeClass("hide")...which is way too annoying.



Add the following JavaScript code after the initial jQuery .js file load and all is well.

var originaljQueryShow = jQuery.fn.show;
var originaljQueryHide = jQuery.fn.hide;
jQuery.fn.extend({
    show: function () {
        var result = originaljQueryShow.apply(this, arguments);
        jQuery(this).removeClass("hide");
        return result;
    },
    hide: function () {
        var result = originaljQueryHide.apply(this, arguments);
        jQuery(this).addClass("hide");
        return result;
    }
});


This lets the original functionality of the jQuery show() and hide() to be maintained, while adding transparent support for the Bootstrap css hide class.

7 comments:

Anonymous

Nice blog. Thanks for sharing such informative blog.

Unknown

Superb post. Impressive writing skill. Thank u so much for sharing with us.
Selection Process of Police Govt Jobs

Mahesh chaube

Great article admin. i love the way you summarized this post.

lots of love from: Ramadan Song

krishna


Amazon cashback offers 2018Cashback Deals with sbi,hdfc,icici,axis banks,credit&debit card,
Amazon Cashback Offers 2018 Upto 65% Cashback Deals, AMAZON CASHBACK OFFERS 2018, DISCOUNT COUPON OFFERS 2018, Amazon cashback offers with sbi hdfc icici axis banks credit&debit card offers more. amazon cashback offers2018,amazon india cashback,amazon offers on mobiles,amazon cashback2018,amazon offers 2018



cashbackoffer amazon coupon code| amazon coupon promo code| amazon offer coupon code|
amazon coupon code| amazon coupon promo code| amazon offer coupon code


About Airport Parking,Accor HotelsAffordable Asia,Agoda,Air Asia Go,Akbar Travels,Amoma,Azores Getaways,Big Bus Tours,Booking,CarmelLimo,CatchThatBus,CheapAir,CheapTickets Singapore,Cleartrip,Ctrip English speaking,Etihad Airways,Expedia,Expedia India, Expedia Indonesia Hotels, Flights & Packages,Travel Coupons, Offers: Flights, Hotels, Bus Promo Codes
accor HotelsAffordable Asia,Agoda,Air Asia Go,Akbar Travels,Amoma,Azores Getaways,Big Bus Tours,Booking,CarmelLimo,CatchThatBus,CheapAir,CheapTickets Singapore,Cleartrip,Ctrip English speaking,Etihad Airways,Expedia,Expedia India,

Expedia Indonesia Hotels, Flights & Packages

CashBack Offers, Discount Coupons, Bank Offers & Promo Codes


flipkart cashback offer,
CashBack Offers, Discount Coupons


Pepperfry, Mobikwik, Firstcry, Fab Hotels, Ebay, Aliexpress, Adidas, Healthkart, Pepperfry, Shoppers Stop, FlipKart, Amazon, Lurap, Giftalove, Reebok, SBI Card, CoolWinks, Housejoy, Shine, Jaypore, netmeds, FabAlley, Prettysecrets, FlowerAura, Clovia, Shopclues, Printvenue, Firstcry, Travelguru, Myntra, Zivame, Jabong, Ferns N Petals,Healthkart, Pepperfry, Shoppers Stop, FlipKart, Amazon


CashBack Offers, Discount Coupons, Bank Offers & Promo Codes

krishna



Musafir, My Bus Tickets, Myles, Orbitz, Qatar

Airways, Rehlat, Sixt Car Rental, Skyscanner, SOTC Holidays, Starline Tours, Thomas Cook, Ticket

Goose, Travelguru, Travel Talk Tours, Treebohotels


,Credit card offers in jabong,jabong hdfc

Cashback,jabong icici cashback,jabong sbi cashback,
Jabong Cashback Offers & Discount Coupons 2018 : Extra 20% Offer,jabong coupons, jabong offers,

hdfc jabong offer, icici jabong offer 2018, jabong footwear, sbi jabong offer, jabong axis bank

offer, jabong sbi offer 2018,jabong cashback Offers, jabong cashback, jabong Deals,Credit card

offers in jabong,jabong hdfc Cashback,jabong icici cashback,jabong sbi cashback ,jabong axis

cashback,jabong offers,Jabong cashback coupons,jabong offers


Online Sale - Online Sale Shopping of up

to 70% Of...
zivame cash back offers
Jabong Bank Coupons April 2018 for ICICI, SBI, HDF...
Ferns N Petals
Amazon today's deals great saving every day
Up to 40% off TVs & Appliances + Additional 10% cashback offers


amazon cashback offers,Amazon Cashback

Offers May 2018 Upto 65% Cashback Deals,Amazon cashback offers January,Amazon cashback offers

February,amazon cashback march,Amazon offers april , Cashback offers may , August cashback

amazon , September offers cashback November , Cashback offers on December , HDFC Credit card

offers on amazon,Axis Bank credit card offer on amazon,ICICI bank offers in amazon,Citi bank

cashback on amazon


Amazon cashback offers

January , Amazon cashback offers February , amazon cashback march , Amazon offers april ,

Cashback offers may , August cashback amazon , September offers cashback November , Cashback

offers on December , HDFC Credit card offers on amazon , Axis Bank credit card offer on amazon ,

ICICI bank offers in amazon , Citi bank cashback on amazon


make my trip citi credit and debit cards

offers:- ...
make my trip International hotel jaw -dropping dea...
make my trip first night free on 1st hotel booking...
Hurry! Get exciting discounts on Hotels & Flights ...
akbartravels save big upto 1000 off on flight book...
Exclusive offer: Get 15% OFF on HOTELS with Visa f...
Exclusive offer: Get 15% OFF on HOTELS with Visa ...
(10 may 18) : TRAVELSPICE 5 Star Hotels at 3 Star ...
Travelspice - 10 may 18 cashback offers
maake my trip anniversary trvel sale best deal int...
Makemytrip International Flights latest deals on ...
TopTravel Websites cashback offers &discounts upto


"Cashback Offers Coupons Offers you

dozens of Cashback offers with your Credit / debit / Net banking for Top eCommerce,cash back

offers coupons


Ferns N Petals ,ferns and petals login, ferns

and ...
shopclues paytm offer, shopclues 25 off coupon, sh...
myntra coupons, myntra cashback paytm, myntra hdfc...
Jabong Cashback - Jabong Offers, Cashback & Coupons,Cashback Coupons : CashBack Offers, Discount

Coupons & Promo

Slot เว็บ ตรง

เข้า เล่น pg พีจีสล็อต รองรับโทรศัพท์เคลื่อนที่ทุกระบบ เล่นได้ทุกหนทุกแห่ง แบบเกมนั้น ” รองรับภาษาไทย “ เป็นเกมสล็อตรูปแบบใหม่ pg slot พาทางเข้าเล่นมาให้คุณแล้วคลิกได้เลย

ทดลองpg รับฟรีเครดิต

Kingkong PG ที่น่าเล่น เป็นเกมสล็อตออนไลน์ที่มีความน่าสนใจและเป็นที่นิยมอย่างมากในวงการเกมคาสิโนออนไลน์ โดยเกมนี้มีการออกแบบมาให้เป็นธีมของ PG SLOT