{"title":"Setting Up Sliders with jQuery Plugin","id":51886,"link":"https:\/\/env.averta.net\/en\/step\/setting-up-sliders-with-jquery-plugin\/","parent":[51824],"content":"<p>Although you can use Master Slider without jQuery, it is possible to setup the slider like any other jQuery plugins. In this article you can find an example of setting up the slider with its jQuery plugin.<\/p>\n<p class=\"aswi-text-box box-note\"><strong>Note: <\/strong>Before using this method, make sure that jQuery is already available in the page<\/p>\n<h2>Example<\/h2>\n<pre class=\"lang:xhtml decode:true \">  $(function ($) {\r\n    $('.slider').masterslider({\r\n        width : 1000,\r\n        height : 500,\r\n        \/\/ other slider options here...\r\n        controls: {\r\n          arrows: { autohide:true },\r\n          thumbnails: { autohide:false, dir:'h', align:'bottom' }\r\n        }\r\n    });\r\n  });<\/pre>\n<p>As it demonstrates in the example above, to create a slider with the jQuery plugin, first of all, you need to select all slider markups in the page by jQuery, then call <code>masterslider<\/code> jQuery plugin. You can set all slider options as the plugin&#8217;s first parameter.<\/p>\n<p>In addition, to add a control, like the example, you need to define each UI control in the <code>controls<\/code> options as an object.<\/p>\n<h2>Access slider instance<\/h2>\n<p>If you need to get the slider instance object from the jQuery plugin, you can get it like this example:<\/p>\n<pre class=\"lang:xhtml decode:true \">  var slider =  $('.slider').masterslider('slider');\r\n<\/pre>\n<h2>Adding events<\/h2>\n<p>You can also add slider events like other jQuery events. Below adds init event to the slider<\/p>\n<pre class=\"lang:xhtml decode:true \">  $('.slider').on( 'init', function(){\r\n    \/\/ slider init.\r\n  });<\/pre>\n<h2>Adding actions<\/h2>\n<p>To add an <a href=\"https:\/\/env.averta.net\/en\/step\/getting-to-know-actions\/?b=52038,52038\" title=\"Getting to Know Actions\">action<\/a> callback to the slider by jQuery plugin you can add it like the following example:<\/p>\n<pre class=\"lang:xhtml decode:true \">    $('.slider').masterslider( 'action', 'init', function(){\r\n      \/\/ slider init\r\n    });<\/pre>\n","type":"solution"}