Friday, 8 June 2018

004 BackboneJS Events on, off, Trigger


Events is a module that can be bind  with an object and trigger custom events.you can bind the custom events by using the your custom name.You  do not need to declared events before they are bound.

There are several method of Event
  • on : object.on(event, callback, [context])
       "on" method bind a callback function to an object. The callback will be invoked when a event triggers.

            1)event − It binds an object.

           
2)callback − It is the reference to the code.

            3)context − An java script object that can be passed to a callback function.


Below is the example of "on" method.

Example

<!DOCTYPE html>
<html>
<head>
            <script src="https://code.jquery.com/jquery-2.1.3.min.js" type="text/javascript"></script>
           <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js"
type="text/javascript"></script>
            <script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js"
type="text/javascript"></script>


<script type="text/javascript">
           
   var obj = {};
     _.extend(obj, Backbone.Events);

     obj.on("PassMsg", function (Mymsg)
     {
             document.write(Mymsg);
     });

    obj.trigger("PassMsg", "I am learing BackboneJS");

</script>  

</head>

</html>

Output :



  •  off : object.off([event], [callback], [context])
Clear object with previously-bound callback function . If no context is specified, all of the versions of the callback with different contexts will be removed.


            1)event − It binds an object.

           
2)callback − It is the reference to the code.

            3)context − An java script object that can be passed to a callback function.


Example

<!DOCTYPE html>
<html>
<head>

          <script src="https://code.jquery.com/jquery-2.1.3.min.js" type="text/javascript"></script>
         <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js"
type="text/javascript"></script>
         <script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js"
type="text/javascript"></script>


<script type="text/javascript">
      var obj = {};

      _.extend(obj, Backbone.Events);

        var Function1 = function () 
     {
             document.write('I am learing BackBoneJS
'
);
         };

         var Function2 = function () 
     {
           document.write('I am learing Backbone Events
'
);
        };

        document.write('-------------Before calling off fuction-----------
'
);
         
    obj.on("PassMsg", Function1);
       obj.on("PassMsg", Function2);


       obj.trigger("PassMsg");

       obj.off("PassMsg", Function1);

      document.write('-------------After calling off fuction------Function1 is off-----
'
);

      obj.trigger("PassMsg");
</script>
</head>

</html>

Output

-------------Before calling off fuction-----------
I am learing BackBoneJS
I am learing Backbone Events
-------------After calling off fuction------Function1 is off-----
I am learing Backbone Events


Trigger : Trigger callbacks functions for the given event.

          object.trigger(event, [*args])


          event − It binds an object.

          args − It passes arguments to the callback function.


We will again see the same example to know how trigger works.



<!DOCTYPE html>
<html>
<head>
            <script src="https://code.jquery.com/jquery-2.1.3.min.js" type="text/javascript"></script>
           <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js"
type="text/javascript"></script>
            <script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js"
type="text/javascript"></script>


<script type="text/javascript">
           
   var obj = {};
     _.extend(obj, Backbone.Events);

     obj.on("PassMsg", function (Mymsg)
     {
             document.write(Mymsg);
     });

    obj.trigger("PassMsg", "I am learing BackboneJS");

</script>  

</head>

</html>

Output : 



003 BackboneJS Architecture

BackboneJS is a JavaScript library to manage large code in a smart way. BackboneJS separate business logic and user interface logic and makes the code clean , structured and maintainable.BackboneJS is a kind of design practices that you would to help design better , basically helps organize your code and separate their concerns.
The Below  image show the architecture of .BackboneJS have several modules
  • HTTP request 
  • Router 
  • View 
  • Events  
  • Models 
  • Collections 
  • Data source
HTTP Request : In a BackboneJS application , client request to server via http request. The request can be for file ,document ,image through HTTP protocol. The request message can be come from browser or search engine ect.


Router :It is used for routing the client side applications and connects them to actions and events using URL's.Based on the url fragments you can choose to 'route' your applications logic,you can choose what functions to invoke so you effectively 'route' to the right set of methods based on your logic.


View : BackboneJS create model according to business logic. No HTML markup associated with JavaScript code. When model changes, corresponding view automatically changes without reloading the pages. BackboneJS follow MVC architecture, view and module communicate via event. When a model is changed and event is trigged corresponding view also changes.







Events : Events is the most important part of the BackboneJS application. View and modules communicate via events. BackboneJS bind custom element to an application event can be mixed to any object capable of  binding and triggering object.

Models : Models contain data of an application. Model contain business entity with validation a business logic. Model is responsible to supply data to view  and get data from view for storage. Model is core object of in JavaScript application.

Collections : A collection is a number of  model used  bind event. You can loop through collections and made change respective models. Collection support sorting and filtering. A model structure and instance should be created before creating a collection.Beside from their own events, collections also proxy through all of the events that occur to models within them.

Data source : Data sourc do connection set up to a database from a server and contains the information that is requested from the client. Below is the steps of flow 

       1)User requests for the data using the router, that routes applications to the events using the URL's.

      2)View represents the model's data to the user.

       3)Model and collection retrieves and populates the data from the database by binding custom events.



Thursday, 7 June 2018

002 BackboneJS Setup

BackboneJS is a JavaScript library. No installation is required. You can use BackboneJS by downloading the library or add link of CDN  to the project page. You can download library from official website of BackboneJS or you can download it CDN.
  1. Downloading library from official website.
  2. Downloading library from CDNs.
The advantage of CDN download is that, once in library downloaded from CDN , when the visitor came to that page again no need to download again because the copy of that previous download already there.




You can download BackboneJS library from http://backbonejs.org/, you have noticed that ,there are three option for download.

Development Version : Development Versus gives us the full JavaScript library source ,you can right click and choose "Save as" option to get the development version.

Production Version :
Production Version is the minified version of BackboneJS .You will notice file size is too small compared to the development version. This makes file to download faster when application runs, time consume for download is almost negligible.

Edge Version : Edge Version is under development, message inform you , that you can use it at your own risk, the version is not released yet. To download this version , just right click and choose "Save as" option.



BackboneJS has dependencies

Underscore.js − Hard dependency which must to be included. 


jQuery.js − For RESTful persistence, history support via Backbone.Router and DOM manipulation with Backbone.View. 


json2.js − For older Internet Explorer support. 


Here is the link you need to include in your application , if you are using CDN    

<script src="https://code.jquery.com/jquery-2.1.3.min.js" type="text/javascript"></script>
           <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js"
type="text/javascript"></script>
           <script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js"
type="text/javascript"></script>
      

   

BackboneJS Simple Application Step by Step

1)Write the page HTML


<!DOCTYPE html>
<html>
<head>
<title>Model Example</title>
....
...
</head>
</html>


2)Include the  BackboneJS library



<script src="https://code.jquery.com/jquery-2.1.3.min.js" type="text/javascript"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js"
type="text/javascript"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js"
type="text/javascript"></script>
<script type="text/javascript">

3) Add BackboneJS Code

<script type="text/javascript">

   var myObj = Backbone.Model.extend({ message: "Hellow World" });

   var myObj2 = new myObj();

    document.write(myObj2.message);
</script>


Now the Complted Source is here

<!DOCTYPE html>
<html>
<head>
<title>Model Example</title>

            <script src="https://code.jquery.com/jquery-2.1.3.min.js" type="text/javascript"></script>
           <script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.2/underscore-min.js"
type="text/javascript"></script>
           <script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js"
type="text/javascript"></script>


<script type="text/javascript">

         var myObj = Backbone.Model.extend({ message: "Hellow World" });

         var myObj2 = new myObj();

        document.write(myObj2.message);
</script>

</head>
</html>

 
Output :




001 BackboneJS Introduction

BackboneJS is a lightweight JavaScript library for single page application. The main objective of BackboneJS is to simplify code which is very complex. BackboneJS helps to separate business logic and user interface logic with the help of view , model ,event etc.
BackboneJS support MVC framework with abstract data into model and DOM into view , events binds  models. This is done by supplying models with custom events and key value binding.

BackboneJS is open source  component ,annotated source code are 
available in the internet. It is free and developed by Jeremy Ashkenas , initial release was  October'13 2010.

As we have discussed earlier , BackboneJS help to reduce complication of source code. If you building a very complicated single page application with jquery and JavaScript and you are adding or replacing DOM element or the application showing some animation , maintaining source code is become very complicated, here comes BackboneJS. BackboneJS is used to reduce complications by using models , view , events etc.

  • BackboneJS  has meet front end development much easier by using JavaScript functions.
  • View in HTML update automatically when any model changes.
  • BackboneJS has soft dependency on jquery and hard dependency with underscore.js.
  • BackboneJS help to be organized single page web application or mobile application with all structure format.
  • BackboneJS communicate by event with view and model, this makes code clean , safe , structured format.
  • BackboneJS is free and open source , lots of example are available in the internet.
  • BackboneJS represent data as model, you can create , validate destroy or save to server depending upon your UI action.
  • With the model attribute changes, model trigger change event, that reason re-render new information with DOM.

Wednesday, 6 June 2018

025 Weekend Tour Kalimpong

Kalimpong hill station is under the state of West Bengal , India. It is a hill station at around attitude 4100 feet. Kalimpong district is situated at the north of West Bengal , being heal station the weather of Kalimpong is mild and pleasant. Kalimpong is around 2.5 hour journey from Siliguri.

 





Durpin Monastery : Tibetan Monastery located at the top of durpin Hills. From the terrace of the monastery, you will get a magnificent view of hills and Kalimpong city. If the weather is clear, you can experience the view of Kanchenjunga also.

Delo Park : Delo does attract The Tourist most.
Delo is another hill just opposite side of Durpin monasty. Delo is the highest point of Kalimpong , beautiful garden with flowers , multi cuisine restaurant, you will spend hours after hours here.

 





Army Golf Club : A beautiful Golf course and splendid view of mountain seems like a picture. A scenic 9-hole golf course  maintained by Army authorities. You can experience the view of Lolegaon , if the sky is clear.

Morgan house : Just opposite of Army golf club , old property converted to a hotel . The building
typical colonial architecture and there are many stories around this building .

Jelepla View Point : A magnificent , viewpoint, Confluence of river Teesta, Reang and Relli , you will see from high heel top.

 




Pineview Nursery : A great collection of cactus  other trees.  You will see some unknown cactus and flower. The place is beautifully maintained and well decorated and lots of flower. This place is a private place,the entry fee is 20/-.

Kalimpong is well connected with New Jalpaiguri and Siliguri. A small car take around 2100/- to reach Kalimpong.Share care take around 120/- to reach Kalimpong. Bus services available , ticket fare is 100/- to the per person.

For Kalimpong sightseeing , it take around 1500/- and 4 hours for complete
sightseeing.

You can reach Lava from Kalimpong by car, small car charge around 1000/-.

You can reach
Lolegaon , small car charge around 1000/-.

New Jalpaiguri is well connected with Kolkata and Assam.Several

train are available from Kolkata and Assam to reach New Jalpaiguri.

A lot of hotels are available in Kalimpong, you can book previously or you can come here and book hotel.

024 Weekend Tour Darjeeling

Darjeeling is a hill station  in the state of West Bengal, India. Darjeeling is a district situated and hilly area. Darjeeling is very popular for tourism, mainly people from West Bengal. Darjeeling is popular for its scenic beauty and pleasant weather and tea garden. Weather are very comfortable all around year , in the month of December and January , Darjeeling experience snowfall for few days.






Darjeeling is famous for tea cultivation, Darjeeling tea is famous  for its quality to all around the world. The main attraction of Darjeeling is Mall. Darjeeling Mall situated on the Mall Road , a plane surface  on the hill. Tourist  spend their time hours after hours by sitting on the mall.You will see the magnificent scenic beauty of hills all Around the mall. You will enjoy the scenic beauty with sip of tea or coffee  by sitting on  Mall. You will see that people are riding horse, playing different games, singing with instruments. All Around The Mall there is restaurants, tea shop, food stall ,home decoration element shop etc.


 






 

Troy Train : It is very attractive  for tourist. Is very old heritage, it is come under UNESCO. Troy Train has two  compartment. Ghoom is the world highest station. Generally ,tourist ride Troy Train from Darjeeling to Ghoom and Batasia loop and back again.I have found that the Troy Train is still use coal as fuel.

 







Tea garden:  Darjeeling is famous for its tea production. World highest quality tea are found here. You will notice tea garden all around Darjeeling. The valley of the Darjeeling are full of tea garden , make the scenery more beautiful, you can plunk tea, take photo, you can purchase it from local shop.

 


Padmaja Naidu Himalayan Zoological Park :It is a small zoo with well maintained in hill area. The zoo have  Panda ,Leopard ,Jackal, Bird etc. The entry fee of zoo is RS 60/-. But we could not found a large animals like elephant , horse , crocodile . The main attraction of the zoo is red panda. You will find aquarium and snake house here also.








 

Ghoom Monastery : It is a Buddhist Monastery.You will large Budda idle inside the Monastery.

 


Batasia Loop : Batasia loop is a war Memorial, surrounded buy a loop of Troy train line. Troy train move like a loop here.This is a beautiful place, hill all around the place. If sky is clear , you can see Kanchenjunga and Nepal border from here.



 



Rock Garden : It is a beautiful place, a small stream is falling from high hill step by step. The place is well maintained and decorated by local government authority. Staircase , small road ,bridge are there to move up by walk sound of falling stream. High hill are all around area with full of tea garden create a magnificent ambience.


 





The nearest railway station of Darjeeling is New Jalpaiguri . You can hire a car or share a car. A small car from New Jalpaiguri to Darjeeling take around 2100/-,share taxi take around 150/-. New Jalpaiguri is well connected to Kolkata and Assam, a lot of train available to New Jalpaiguri from Kolkata and Assam.

There are plenty of hotels in Darjeeling , you can Book from Kolkata or book after reaching Darjeeling.

There are many more places to see  Ropeway,   Mahakal Mandir, Japanese Pagoda, local market ect.

You can visit nearby  places 
Tinchuley , Lamahatta, Lepchajagat .

বাঙালির বেড়ানো সেরা চারটি ঠিকানা

  বাঙালি মানে ঘোড়া পাগল | দু একদিন ছুটি পেলো মানে বাঙালি চলল ঘুরতে | সে সমুদ্রই হোক , পাহাড়ি হোক বা নদী হোক। বাঙালির ...