Search Widgets‎ > ‎

Flights Search Widget

In order to implement the search widget, you will need to go through the following steps:
1. Include the script in the HEAD part of your HTML code:
<script src="[innstant whitelabel domain]/static/widgets/FlightsWidget.js" type="text/javascript"></script>
2. Ready your HTML. Create a DIV block where you would like the widget to be located within your HTML dom:
the ID can be anything you like, you will need to pass the selector later to the widget. for example:
<div id="searchForm"></div>
3. When the document is "ready", initialize the widget. the constuct gets the selector for the container, initialization options (see details below), and an optional template:
In case you're using jQuery, you can use the following code:
$( document ).ready(function() {
    new FlightsWidget(document.querySelector('#searchForm'),{'serverUrl':'http://www.example.com/'});
});
Otherwise, you can use this:
document.addEventListener( "DOMContentLoaded", function(){
    document.removeEventListener( "DOMContentLoaded", arguments.callee, false );
    new FlightsWidget(document.querySelector('#searchForm'),{'serverUrl':'http://www.example.com/'});
}, false );

The available options that can be passed to the widget during the initialization sequence are. except for the "serverUrl" which is mandatory, the rest are optional:
 Key Type Description 
 serverUrl URLMandatory - full url to the search server with a trailing slash. example: http://www.example.com/
 defaultOriginAirPort object {id: 0, name: ""} - the terminal id is an integer and the name is free text
 defaultDestinationAirPort object  {id: 0, name: ""} - the terminal id is an integer and the name is free text
 defaultDepartureDate StringYYYY-MM-DD format of the departure date 
 defaultReturningDate String YYYY-MM-DD format of the departure date 
 defaultPaxList Object Pax combination object. for example: {'adults': 2, 'children': []}
 directFlightsOnly Boolean if set to true, only direct flights will be returned
 flexibleDates Boolean if set to true, +/- days will be used in the search process, and the departure and arrival dates may change
 view String Possible values: international / domestic / trans-tasman. the default value (if nothing is set) is "international"
 restoreFromCookie Object When the user submits the search form, the data is stored in their cookie. in order to avoid it, you can set this object.
default values are: {oneWay: true, dates: true, paxList: true, lastAirports: true, flightClass: true} 
 morbaUrl URLnot mandatory, the path from which to use the auto-suggest. useful in case of HTTPS pages. 



Comments