javascript - Set click as default -
i´m using megafolio filter category clic, want set default category when page loads, how can that?
there filter function
function completegallerycontent(data, target, eng) { var items = data.d.results; console.log(items); var menu = ""; var cat = ""; (var item in items) { if(items[item].descriptionenglish==null) items[item].descriptionenglish=""; if(items[item].description==null) items[item].description=""; if(items[item].categoria.results!= null && items[item].categoria.results!= undefined && items[item].categoria.results.length > 0){ cat =setcategories(eng,items[item].categoria.results); } if (eng){ menu += "<div class='mega-entry " + cat + " cat-all' id='mega-entry-1' data-src='" + items[item].encodedabsurl + "' data-width='' data-height='' data-lowsize=''><div class='mega-covercaption mega-square-bottom mega-landscape-right mega-portrait-bottom mega-red'><div class='mega-title'>" + items[item].titleenglish + "</div><p>" + items[item].descriptionenglish + "</p></div><div class='mega-coverbuttons'><div class='mega-link mega-red'></div><a class='fancybox' rel='group' href='" + items[item].encodedabsurl + "' title='" + items[item].titleenglish + "'><div class='mega-view mega-red'></div></a></div></div>"; }else{ menu += "<div class='mega-entry "+ cat + " cat-all' id='mega-entry-1' data-src='" + items[item].encodedabsurl + "' data-width='' data-height='' data-lowsize=''><div class='mega-covercaption mega-square-bottom mega-landscape-right mega-portrait-bottom mega-red'><div class='mega-title'>" + items[item].title + "</div><p>" + items[item].description + "</p></div><div class='mega-coverbuttons'><div class='mega-link mega-red'></div><a class='fancybox' rel='group' href='" + items[item].encodedabsurl + "' title='"+ items[item].title +"'><div class='mega-view mega-red'></div></a></div></div>"; } } $(target).html(menu); var api = $(target).megafoliopro( { filterchangeanimation: "pagebottom", // fade, rotate, scale, rotatescale, pagetop, pagebottom,pagemiddle filterchangespeed: 400, // speed of transition filterchangerotate: 99, // if ue scalerotate or rotate can set rotation (99 = random !!) filterchangescale: 0.6, // scale animation endparameter delay: 20, defaultwidth: 980, paddinghorizontal: 10, paddingvertical: 10, layoutarray: [9, 11, 5, 3, 7, 12, 4, 6, 13] // defines layout types can used in gallery. 2-9 or "random". can define more one, {5,2,6,4} first items orderd in layout 5, next comming items in layout 2, next comming items in layout 6 etc... can use simple {9} item ordered in layout 9 type. }); //console.log("entra"); // fancy box ( live box) media support jquery(".fancybox").fancybox(); //console.log("sale"); // filter function $('.filter').click(function () { $('.filter').each(function () { jquery(this).removeclass("selected") }); api.megafilter(jquery(this).data('category')); $(this).addclass("selected"); }); var categoryselected = getparameterbyname("category"); $("div[data-category='"+categoryselected +"']").click(); }
i try change these line these did´t works:
var categoryselected = getparameterbyname("office");
or like
var categoryselected = getparameterbyname().first;
to take first 1 populated of db
with jquery, can use click() function :
$(document).ready(function(){ $('[href="#first_steps"]').click(); });
just change first_steps other link if want.
edit
with data-category :
$('[data-category="office"]').click(); // html attribute value
Comments
Post a Comment