// launch the research box in the layout function launchSearch() { $("#js_search").on('click', function(event) { event.preventDefault(); var $container = $('.main'), searchBox = ''; // the html to be injected in the dom if ($(".search_box").length == 0) { // if the box exist already in the dom, don't load again if ($("body").hasClass("no_masonry")) {// if where are not in masonry, inject in $("#main").prepend( searchBox ); } else { $container.prepend( searchBox ).masonry( 'reload' ); } }; $('#searchForm').on('submit', function(e) { e.preventDefault(); document.location = this.action + '&keyword=' + this.keyword.value; return false; }); }); $('#searchForm').on('submit', function(e) { e.preventDefault(); document.location = this.action + '&keyword=' + this.keyword.value; return false; }); };