Category: Bootstrap

Bootstrap dropdown hidden issue in table

In this post we’ll see that, how we can solve the bootstrap dropdown issue when we use the dropdown inside the table or any element with overflow:hidden property. so when you add a bootstrap dropdown button inside a table row and apply the overflow hidden on table container it will hide your dropdown in open state.

For example:

This is sample HTML of your issue:

and this your css for table wrapper

This is your output of your HTML and CSS. you can see dropdown is hidden inside table.

dropdown-hide

To solve this problem we need to two things:

  1. First capture the event of bootstrap dropdown button when dropdown show and hide
    • show.bs.dropdown
    • hide.bs.dropdown
  2. Second inside this event we will check the current target offset(.offset()) and outer height of the current target(.outerHeight());

Here is the full code:

Now run your HTML in browser and see your issue is solved

Thanks for reading. Happy Learning!!!

Windows devices touch issues

In this article i will show you how we can solve the touch issue in windows devices. Now a days we have lot’s of devices are available in the market. So when we are creating a responsive site we have to first fix the device requirement specification from client because we must sure it work properly, user friendly in every device mobile,tablet and desktop and¬†every platform like android,iOS and windows .

Every devices have different specification about touch and it behaves differently. In windows we mostly use IE who handle the touch events differently but in webkit it supports a touch interface that is separate from mouse handling and IE groups the touch,mouse and stylus into a single interface(pointer) it also has been submitted in W3C specification pointer events.

In windows devices IE pointer events model have custom gesture to indicate the area of the page by default gesture handling(pan). we can turn off default gesture handling by using this property -ms-touch-action for example.

However, IE10 on Windows Phone 8 also supports the pan-x and pan-y value of -ms-touch-action property which specify that the browser should handle horizontal or vertical gestures to solve the touch issues in windows, and custom JavaScript handlers should handle everything else.

Note  Microsoft vendor prefixed version of this event (-ms-touch-action) is no longer supported in IE11 and may be removed in a future release. Instead, use the non-prefixed name touch-action, which is better for standards compliance and future compatibility.

Syntax

When a we¬†touches an element, that element’s touch-action property determines the default touch behaviors permitted for that contact, like panning or zooming.

Property values

One of the following values, a combination of the gesture values.

auto
Initial value. Indicates the Windows Store app using JavaScript will determine the permitted touch behaviors for the element.
none
The element permits no default touch behaviors.
pan-x
The element permits touch-driven panning on the horizontal axis. The touch pan is performed on the nearest ancestor with horizontally scrollable content.
pan-y
The element permits touch-driven panning on the vertical axis. The touch pan is performed on the nearest ancestor with vertically scrollable content.
pinch-zoom
The element permits pinch-zooming. The pinch-zoom is performed on the nearest ancestor with zoomable content.
manipulation
The element permits touch-driven panning and pinch-zooming. This is the shorthand equivalent of “pan-x pan-y pinch-zoom”.
double-tap-zoom
The element permits double-tap-zooming. The double-tap-zoom is performed on the full page. Double-tap-zoom is not available in Windows Store apps using JavaScript.
cross-slide-x
The element permits cross-sliding along the horizontal axis.
cross-slide-y
The element permits cross-sliding along the vertical axis.

For more information about web development for windows click here

What is Modernizr

Modernizr is a small piece of JavaScript code library for feature detection that detects the browser support next-generation web technologies in your user’s browsers. Modernizr uses feature detection to allow you to easily fit¬†your website on user’s experiences based with the¬†actual capabilities of their browser.

There are several JavaScript libraries are available now a days, which can help you detect features and browsers. Using these libraries we can detect whether the browser has support for that particular feature or not.

Modernizr gives the ability to detect the new features in the browsers that can render or utilize

Let’s take a¬†example with¬†plain javascript to detect¬†canvas feature.

In this code, we tried to create a canvas element and then added it to body.

we could use the Modernizr.canvas property to test if the browser supported canvas or not:

Modernizr creates an object named Modernizr to the document, which contains all of the test results as Boolean properties. We can write a simple script to list all supported and unsupported features:

Polyfilling with YepNope,requireJS

As a Developer, we can load the JS as per the feature is supported by your browsers. We can use Modernizr.load() method to test if a certain feature is supported or not and load the appropriate JavaScript based on the result. Unfortunately Modernizr.load() is not provided in the modernizr.js file by default and was a part of Modernizr Version 2.8.3. But there are many other third party libraries are available to load resources like YepNope,requireJS,HeadJS etc.

Modernizr.load() is actually yepnope.js (http://yepnopejs.com/). yepnope.js was known as a conditional loader for polyfills, but now its deprecated after version 1.5.

Let’s take a example for this:

In below code we are checking if touch is available in the browser then it will load touch.js, otherwise it will load the no-touch.js file into the browser.

For the newer versions of Modernizr, we can include yepnope.js to use Modernizr.load().

Developers can also wrote the previous example of code as below with RequireJS:

AngularJS Starter Templete With Bootstrap

If you have not tried yet to create angularjs website then definitely this article will help you to create angularjs website with bootstrap starter template. So let’s start.

In this example i am using bootstrap “Justified¬†nav” template.

thumbnail

These are the following AngularJs features what we will covered with creating this template

  1. MVC(Model view Controller) Architecture
  2. Calling JSON service with factory
  3. Dependency Injection
  4. AngularUI Bootstrap
  5. Routing
  6. Directives
  7. Image Gallery with AngularJS

At the end of the article you understand what is MVC Architecture and how it works in AngularJS? | AngularJS MVC
MVC: It’s a design pattern that breaks the application into three parts Model View Controller. Using a pattern is a reusable solution but in regular javascript we organize the code differently. Another way of looking at patterns are as a templates which can be used in quite a few different scenarios.

Model:

Model is belongs to data it can be dynamic data or static which means you can get it from a database like Mongodb and you can also get data from static JSON file.

Let’s create a static JSON to defining a model. Add following lines in a data.json file.

View:

View is displaying the data of model. For this we use double curly brackets and it is lot like using JavaScript template library (like mustache.js).

Let’s create a view, following this instruction in index.html:

  • First¬†declare¬†the¬†name¬†of¬†the¬†application¬†using¬†ng-app¬†directive.
  • Download¬†and¬†add¬†the¬†angular¬†library¬†in¬†your¬†page¬†version¬†–¬†v1.3.0-rc.5.
  • Defining¬†the¬†controller¬†name¬†using¬†ng-controller¬†directive¬†in¬†your¬†parent¬†element.

    Let’s combined the code:

In this HTML we have use ng directives to rendering the data in view.

ng-repeat: The ngRepeat directive instantiates a template once per item from a  collection. Each template instance gets its own scope, where the given  loop variable is set to the current collection item, and $index is set to  the item index or key.

ng-init: The ngInit directive allows you to evaluate an expression in the current  scope.

ng-click: The ngClick directive allows you to specify custom behavior when an   element is clicked.

ng-show: The ngShow directive shows or hides the given HTML element based on    the expression provided to the ngShow attribute.

Controller

It controls how data is retrieved and displayed to end-user. which means Controller gives you control over model and view.

Creating angular module name which we have defined in ng-app directive in HTML.

We can also defined the dependency as per the module using [] brackets. For our application we need ngRoute for routing to navigate the site. For this you have to download and include

AngularUI¬†Bootstrap¬†‚Äúui.bootstrap‚Ä̬†using¬†the¬†angular¬†bootstrap¬†component.,¬†you¬†can¬†download¬†the¬†library¬†from¬†this¬†link¬†https://angular-ui.github.io.¬†and¬†add¬†in¬†html¬†page.

Creating Factory in Angularjs

AngularJS provides you three ways to create a service : factory,service and provider. A factory is a simple function which allows you to add some logic before creating the object. It returns the created object.

Scope is the glue between application controller and the view. During the template linking phase the directives set up $watch expressions on the scope. The $watch allows the directives to be notified of property changes, which allows the directive to render the updated value to the DOM.

If you find AngularJS MVC Article helpful please share it and comment below.

You can get the full code from here: https://github.com/harmeet090/Angularjs

What’s new in Bootstrap 4 alpha

Bootstrap 4 comes with ton of major changes so it’s impossible to cover them all in detail here, so here are some of our most major changes:

  • Moved from Less to Sass:Using Libsass bootstrap now compiles Sass faster then ever, and also joined large community of Sass developers.
  • Improved grid system: Bootstrap now have added a new grid standard to better target mobile devices.
  • Flexbox support: The future of web is now change a boolean variable and recompile your CSS to take advantage of a flexbox-based grid system and components.
  • Customization is easy:In Bootstrap 4 Now It’s easy to customize the some CSS style options instead of creating new style of like box-shadows,text-shadows transitions, gradients, and more to a separate stylesheet like v3, bootstrap moved all these options into Sass variables. If we want default transitions on everything or to disable rounded corners? Simply we just need to update a variable in Sass and recompiled it.
  • Drop IE8 support and moved to rem and em units: Bootstrap 4 dropped support for IE8 and we can take advantage of the CSS3 without being held back with CSS hacks or fallbacks. Typography Pixels have been swapped for rems and ems where appropriate to make responsive and component sizing even easier. If you need IE8 support, keep using Bootstrap 3.
  • Rewrote all our JavaScript plugins: Every plugin has been rewritten in ES6 to take advantage of the newest JavaScript enhancements. They also now come with UMD support, generic teardown methods, option type checking, and tons more.
  • Tooltips and Popovers: Bootstrap 4 improved auto-placement of tooltips and popovers using library called Tether.

And many other things like Custom form controls, margin and padding classes, new utility classes, and more have also been included.

Know more about Bootstrap 4 head to the v4 alpha docs!

One more thing…

Bootstrap 4 alpha also launching our latest side project, Official Bootstrap Themes.