Reputation: 9966
I have a standard form in my MVC project, where I have a DropDownList. When I change the value of the dropdownlist, the whole pages reloads as it results in a postback.
I do not expect this behavior, and I am trying to stop the dropdownlist for doing a postback.
However, this is where it gets weird. I define my dropdownlist in the following way:
@Html.DropDownList("sortOrder", null, new { onchange = "startUpdate(this)" })
Ignoring Javascipt, there is nothing that would expect me to make a postback. If we include the whole form, we can see that is the case as well here:
@using (var form = Html.BeginForm("Query", "Search", FormMethod.Get, new { id="queryform", name="queryform", onsubmit = "startUpdate(this); return false;"}))
{
<b>Sorter efter</b><br />
@Html.DropDownList("sortOrder", null, new { onchange = "startUpdate(this)" })<br />
</div>
<br />
<input type="submit" class="button_green" value="Søg igen ►" id="SearchButton" name="SearchButton" style="float: left;" onclick="_gaq.push(['_trackEvent', 'Ads_listing', 'search_again_click']); startUpdate(this); return false;" />
<input type="reset" class="button_small" value="Nulstil" id="ClearButton" style="float: right;" />
</text>
}
However, now a smart person might say:
"try to disable JavaScript, and see what happens"
So I did. And then the postback did NOT happen. So my problem, most likely, originates from some JavaScript.
Only problem? I cannot seem to find it.
I have cleared all JavaScript I could imagine that have ANYTHING to do with it, yet it still gives me a postback.
So, sorry, I have to include all my rendered markup, in the hopes that you guys can help me with this big problem (the select html element is called sortOrder
):
(I could not copy whole HTML, so I removed some sections - a production version can be seen at http://www.amino.dk/virksomhedsbors/search/query?transactionType=2&text=§orList=&priceFrom=&priceTo= )
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="da-dk">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Virksomheder til salg</title>
<script type="text/javascript">var _sf_startpt = (new Date()).getTime()</script>
<link href="/styles/saxis.min.css?v=1" rel="Stylesheet" type="text/css" />
<link target="_blank" href="http://fonts.googleapis.com/css?family=Lato:300,400,700,900" rel="stylesheet" type="text/css">
<link href="http://www.amino.dk/virksomhedsbors/rss.aspx" rel="alternate" title="Virksomheder købes og sælges" type="application/rss+xml" />
<link href="http://www.amino.dk/virksomhedsbors/rss.aspx?type=buy" rel="alternate" title="Virksomheder købes" type="application/rss+xml" />
<link href="http://www.amino.dk/virksomhedsbors/rss.aspx?type=sell" rel="alternate" title="Virksomheder til salg" type="application/rss+xml" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script type="text/javascript" src="http://eas4.emediate.eu/EAS_tag.1.0.js"></script>
<script type="text/javascript" src="/Assets/js/global.js?2.0"></script>
<script type="text/javascript" src="/user/infobox?635467592356980146"></script>
<script type="text/javascript">
$(document).ready(function () {
$.ajaxSetup(
{ cache: false }
);
}
);
</script>
<style type="text/css">
<!--
.cell {
padding-left: 15px;
}
-->
</style>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-10494982-1']);
_gaq.push(['_setDomainName', '.amino.dk']);
_gaq.push(['_setCustomVar', 1, 'Medlemstype', 'Ikke registreret', 1]);
_gaq.push(['_setCustomVar', 2, 'VB-type', 'Ikke registreret', 1]);
document.referrer.match(/https?:\/\/[^/]*google\..*[?&]cd=([^&]*)/gi);
var gaqgr = RegExp.$1;
if (gaqgr) {
_gaq.push(['_setCustomVar', 3, 'GoogleRank', gaqgr, 2]);
}
_gaq.push(['_trackPageview']);
_gaq.push(['_trackPageLoadTime']);
(function () {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div id="background_body">
<div id="topad" style="clear: both; text-align: center; margin: 0 auto 10px">
<div id="EAS_c13cb956" style="width:930px;height:180px;margin:0 auto;border:0;padding:0;"></div>
<script type="text/javascript">
$(document).ready(function() {
EAS_load_fif("EAS_c13cb956", "/EAS_fif.html", "http://eas4.emediate.eu/eas?cu=1202;cre=mu;js=y;target=_blank;ord=635467592356990147", 930, 180);
});
</script>
</div>
</div>
</div>
<div id="body">
<div id="contentBody">
<div id="sidead" style="position: fixed; width: 300px; height: 600px; margin-left: 963px; top:180px;">
<div id="EAS_5408e9fb" style="width:300px;height:600px;margin:0 auto 0 0;border:0;padding:0;"></div>
<script type="text/javascript">
$(document).ready(function() {
EAS_load_fif("EAS_5408e9fb", "/EAS_fif.html", "http://eas4.emediate.eu/eas?cu=13120;cre=mu;js=y;target=_blank;ord=635467592359750304", 300, 600);
});
</script>
</div>
<div id="UserInformation" style="display: none;"></div>
<div class="column left" style="width: 698px;">
<div class="contentBoxtitle2">
<span style="float: right; margin-right: 5px; margin-top: 5px;" id="SAAdd" class="SearchAgentButton"><a href="javascript:void(0);" onclick=" _gaq.push(['_trackEvent', 'Ads_listing', 'add_searchagent_click']); addSearchAgent(); ">Tilføj som søgeagent</a></span>
<h1 class="contentBoxtitle_home" style="width: 395px; text-overflow: ellipsis; white-space: nowrap; overflow: hidden;" id="searchtitle">Virksomheder til salg</h1>
</div>
<div id="searchResults">
<div class="contentBoxSubtitle2">
<h2>
Viser <u>1</u> til <u>30</u> af i alt <u>1383</u>
<div style="float: right;">
<< Forrige
|
1 |
<a href="/search/query?transactiontype=2&pagesize=30&pageno=2&sortorder=0">2</a>
|
<a href="/search/query?transactiontype=2&pagesize=30&pageno=3&sortorder=0">3</a>
|
<a href="/search/query?transactiontype=2&pagesize=30&pageno=4&sortorder=0">4</a>
|
<a href="/search/query?transactiontype=2&pagesize=30&pageno=5&sortorder=0">5</a>
|
<a href="/search/query?transactiontype=2&pagesize=30&pageno=6&sortorder=0">6</a>
|
<a href="/search/query?transactiontype=2&pagesize=30&pageno=7&sortorder=0">7</a>
|
<a href="/search/query?transactiontype=2&pagesize=30&pageno=2&sortorder=0">Næste >></a>
</div>
</h2>
</div>
<div class="contentBox2">
<script type="text/javascript">
var sortLink = "/search/query?transactionType=2&text=&priceFrom=&priceTo=&yearFrom=&yearTo=&saleReasons=&canMove=&regions=&operatingRegions=&allOperatingRegionsRequired=&sectors=&allSectorsRequired=&financingAvailable=&country=&pageSize=30&sortOrder={sortOrder}&";
</script>
<div style="text-align: right; margin-bottom: 3px;">Sorter efter <select id="order" name="order" onchange="top.location.href=sortLink.replace("{sortOrder}", this.value); "><option selected="selected" value="0">Relevans</option>
<option value="1">Oprettelsesdato (nyeste først)</option>
<option value="2">Oprettelsesdato (ældste først)</option>
<option value="3">Redigeringsdato (nyeste først)</option>
<option value="4">Redigeringsdato (ældste først)</option>
<option value="5">Pris (højeste først)</option>
<option value="6">Pris (laveste først)</option>
</select></div>
<div class="silverbox even" style="">
<div class="ribbon silver"></div>
<p class="adtitle">
<a href="/saelges/handel/agenturhandel/btb-og-btc-udklaedning-legetoej-og-kostumer-inkl-varelager-til-salg-19115">BtB og BtC Udklædning, legetøj og kostumer inkl varelager til salg</a>
<img src="/images/icon_unlock20x25.png" alt="Du kan kontakte denne annonce" style="width: 20px; height: 25px; border: none;" />
</p>
<p class="regions">Midtjylland</p>
<div class="price"><span class="pricelabel">Udbudspris:</span> <span class="pricevalue">895.000 DKK</span></div>
<div class="category"><span class="categorylabel">Forretningsområde:</span> <span class="categoryvalue">Agenturhandel</span></div>
<p class="description">Velkendt engros firma der handler med udklædning, kostumer og legetøj. Mange faste kunder spredt over hele landet giver en god stabil omsætning. Salget foregår via hjemmeside og kundebesøg<b>...</b></p>
<p class="seemore">
Se flere virksomheder til salg inden for:<br />
<a href="/saelges/handel/agenturhandel">Agenturhandel</a>
</p>
<p class="date" style="float: right; clear: both; text-align: right;">
Senest redigeret 16-09-2014
</p>
</div>
<br />
<br />
</div>
<div class="contentBoxSubtitle2">
<h2>
Viser <u>1</u> til <u>30</u> af i alt <u>1383</u>
<div style="float: right;">
<< Forrige
|
1 |
<a href="/search/query?transactiontype=2&pagesize=30&pageno=2&sortorder=0">2</a>
|
<a href="/search/query?transactiontype=2&pagesize=30&pageno=3&sortorder=0">3</a>
|
<a href="/search/query?transactiontype=2&pagesize=30&pageno=4&sortorder=0">4</a>
|
<a href="/search/query?transactiontype=2&pagesize=30&pageno=5&sortorder=0">5</a>
|
<a href="/search/query?transactiontype=2&pagesize=30&pageno=6&sortorder=0">6</a>
|
<a href="/search/query?transactiontype=2&pagesize=30&pageno=7&sortorder=0">7</a>
|
<a href="/search/query?transactiontype=2&pagesize=30&pageno=2&sortorder=0">Næste >></a>
</div>
</h2>
</div>
</div>
<div class="contentBoxFooter2"></div>
</div>
<div class="column">
<div class="box">
<p class="title">Indskrænk/ændre søgning</p>
<div class="boxbody">
<form action="/search/query" id="queryform" method="get" name="queryform" onsubmit=" return false;">
Din rolle er:<br/> <input checked="checked" id="trsBuyer" name="transactionType" onclick="startUpdate(this)" type="radio" value="2" /> <label for="trsBuyer">Køber</label> <input id="trsSeller" name="transactionType" onclick="startUpdate(this)" type="radio" value="1" /> <label for="trsSeller">Sælger</label><br />
<br />
<b>Søgeord:</b><br />
<input id="text" name="text" onkeypress="startUpdate(this)" onkeyup="startUpdate(this)" style="width: 210px;" type="text" value="" /><br />
<br />
<b>Forretningsområder:</b><br />
<a href="javascript:void(0);" onclick=" $(this).hide(500); $('#secadv').show(500); ">Avanceret ►</a><span id="secadv" style="display: none;"><input id="allSectorsRequired" name="allSectorsRequired" onclick=" " style="margin-top: 2px;" type="checkbox" value="true" /><input name="allSectorsRequired" type="hidden" value="false" /> <label for="allSectorsRequired">Alle er påkrævet (OG-søgning)</label></span>
<input type="checkbox" onclick=" " name="sectors" value="12" id="sector12" />
<label for="sector12"> Transportmiddelindustri</label></div>
</div>
</div>
<br />
<a id="showadvprops" href="javascript:void(0);" onclick=" _gaq.push(['_trackEvent', 'Ads_listing', 'search_advanced_criteria']); showAdvancedProps(); ">Vis avancerede kriterier ►</a>
<a id="hideadvprops" href="javascript:void(0);" onclick=" showAdvancedProps(); " style="display: none;">Skjul avancerede kriterier ◄</a><br />
<br />
<div id="advsearch" style="display: none;">
<b>Beliggenhed:</b><br />
<div style="height: 100px; overflow: auto; border: 1px solid #999; padding: 1px 1px 1px 1px; margin-top: 2px;">
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Nordjylland">
<input type="checkbox" name="regions" onclick=" " value="1" id="region1" />
<label for="region1"> Nordjylland</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Midtjylland">
<input type="checkbox" name="regions" onclick=" " value="2" id="region2" />
<label for="region2"> Midtjylland</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Syd- og Sønderjylland">
<input type="checkbox" name="regions" onclick=" " value="3" id="region3" />
<label for="region3"> Syd- og Sønderjylland</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Fyn">
<input type="checkbox" name="regions" onclick=" " value="4" id="region4" />
<label for="region4"> Fyn</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Sjælland, Øerne og Bornholm">
<input type="checkbox" name="regions" onclick=" " value="5" id="region5" />
<label for="region5"> Sjælland, Øerne og Bornholm</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Storkøbenhavn">
<input type="checkbox" name="regions" onclick=" " value="6" id="region6" />
<label for="region6"> Storkøbenhavn</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Ikke oplyst">
<input type="checkbox" name="regions" onclick=" " value="7" id="region7" />
<label for="region7"> Ikke oplyst</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Hele landet">
<input type="checkbox" name="regions" onclick=" " value="8" id="region8" />
<label for="region8"> Hele landet</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Udlandet">
<input type="checkbox" name="regions" onclick=" " value="9" id="region9" />
<label for="region9"> Udlandet</label></div>
</div>
<br />
<b>Opererer i:</b><br />
<a href="javascript:void(0);" onclick=" $(this).hide(500); $('#regadv').show(500); ">Avanceret ►</a><span id="regadv" style="display: none;"><input id="allOperatingRegionsRequired" name="allOperatingRegionsRequired" onclick=" " style="margin-top: 2px;" type="checkbox" value="true" /><input name="allOperatingRegionsRequired" type="hidden" value="false" /> <label for="allOperatingRegionsRequired">Alle er påkrævet (OG-søgning)</label></span>
<div style="height: 100px; overflow: auto; border: 1px solid #999; padding: 1px 1px 1px 1px; margin-top: 2px;">
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Nordjylland">
<input type="checkbox" name="operatingRegions" onclick=" " value="1" id="operatingregion1" />
<label for="operatingregion1"> Nordjylland</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Midtjylland">
<input type="checkbox" name="operatingRegions" onclick=" " value="2" id="operatingregion2" />
<label for="operatingregion2"> Midtjylland</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Syd- og Sønderjylland">
<input type="checkbox" name="operatingRegions" onclick=" " value="3" id="operatingregion3" />
<label for="operatingregion3"> Syd- og Sønderjylland</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Fyn">
<input type="checkbox" name="operatingRegions" onclick=" " value="4" id="operatingregion4" />
<label for="operatingregion4"> Fyn</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Sjælland, Øerne og Bornholm">
<input type="checkbox" name="operatingRegions" onclick=" " value="5" id="operatingregion5" />
<label for="operatingregion5"> Sjælland, Øerne og Bornholm</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Storkøbenhavn">
<input type="checkbox" name="operatingRegions" onclick=" " value="6" id="operatingregion6" />
<label for="operatingregion6"> Storkøbenhavn</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Ikke oplyst">
<input type="checkbox" name="operatingRegions" onclick=" " value="7" id="operatingregion7" />
<label for="operatingregion7"> Ikke oplyst</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Hele landet">
<input type="checkbox" name="operatingRegions" onclick=" " value="8" id="operatingregion8" />
<label for="operatingregion8"> Hele landet</label></div>
<div style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis; height: 18px; line-height: 18px;" title="Udlandet">
<input type="checkbox" name="operatingRegions" onclick=" " value="9" id="operatingregion9" />
<label for="operatingregion9"> Udlandet</label></div>
</div>
<br />
<b>Prisinterval:</b><br />
<input id="priceFrom" name="priceFrom" onkeypress=" " onkeyup=" " style="width: 75px;" type="text" value="" /> til <input id="priceTo" name="priceTo" onkeypress=" " onkeyup=" " style="width: 75px;" type="text" value="" />
<br />
<br />
<b>Etableringsår:</b><br />
<input id="yearFrom" name="yearFrom" onkeypress=" " onkeyup=" " style="width: 75px;" type="text" value="" /> til <input id="yearTo" name="yearTo" onkeypress=" " onkeyup=" " style="width: 75px;" type="text" value="" />
<br />
<br />
<b>Virksomheden skal kunne flyttes:</b><br />
<input checked="checked" id="canMoveNI" name="canMove" onclick=" " type="radio" value="" /> <label for="canMoveNI">Ikke vigtigt</label><br />
<input id="canMoveNo" name="canMove" onclick=" " type="radio" value="0" /> <label for="canMoveNo">Nej</label><br />
<input id="canMoveYes" name="canMove" onclick=" " type="radio" value="1" /> <label for="canMoveYes">Ja</label><br />
<br />
<b>Sælgerfinansiering skal tilbydes:</b><br />
<input checked="checked" id="financingAvailableNI" name="financingAvailable" onclick=" " type="radio" value="" /> <label for="financingAvailableNI">Ikke vigtigt</label><br />
<input id="financingAvailableNo" name="financingAvailable" onclick=" " type="radio" value="0" /> <label for="financingAvailableNo">Nej</label><br />
<input id="financingAvailableYes" name="financingAvailable" onclick=" " type="radio" value="1" /> <label for="financingAvailableYes">Ja</label><br />
<br />
<b>Sorter efter</b><br />
<select id="sortOrder" name="sortOrder" onchange=" "><option selected="selected" value="0">Relevans</option>
<option value="1">Oprettelsesdato (nyeste først)</option>
<option value="2">Oprettelsesdato (ældste først)</option>
<option value="3">Redigeringsdato (nyeste først)</option>
<option value="4">Redigeringsdato (ældste først)</option>
<option value="5">Pris (højeste først)</option>
<option value="6">Pris (laveste først)</option>
</select><br />
</div>
<br />
<input type="submit" class="button_green" value="Søg igen ►" id="SearchButton" name="SearchButton" style="float: left;" onclick=" _gaq.push(['_trackEvent', 'Ads_listing', 'search_again_click']); return false; " />
<input type="reset" class="button_small" value="Nulstil" id="ClearButton" style="float: right;" />
</form> </div>
<div class="boxfooter"></div>
</div>
<br />
<div id="EAS_f01c93ec" style="width:240px;height:auto;margin:0 auto;border:0;padding:0;"></div>
<script type="text/javascript">
$(document).ready(function() {
EAS_load_fif("EAS_f01c93ec", "/EAS_fif.html", "http://eas4.emediate.eu/eas?cu=1193;cre=mu;js=y;target=_blank;ord=635467592356970145", 240, 400);
});
</script>
</div>
<div style="clear: both;"></div>
<br />
<div id="bottomad" style="clear: both; text-align: center; margin: 0 auto 10px">
<div id="EAS_3b18704e" style="width:930px;height:180px;margin:0 auto;border:0;padding:0;"></div>
<script type="text/javascript">
$(document).ready(function() {
EAS_load_fif("EAS_3b18704e", "/EAS_fif.html", "http://eas4.emediate.eu/eas?cu=9947;cre=mu;js=y;target=_blank;ord=635467592359760305", 930, 180);
});
</script>
</div>
<div class="contentHeader"></div>
<div class="CommonContentBox">
<script language="javascript" type="text/javascript" src="http://www.amino.dk/content/amino-partners.js"></script>
</div>
<div class="contentFooter"></div>
</div>
<div style="clear: both;"></div>
</div>
<!-- (C)2000-2009 Gemius SA - gemiusAudience / amino.dk / Virksomhedsbors -->
<script type="text/javascript">
<!-- //--><![CDATA[//><!--
//modified 2013-02-11 rjs as per user specs. updates on gemius
var pp_gemius_identifier = 'bQ0w24csi_1RJcq7a4IMCqdFHWxgAe_a9eJp1cOw7Gf.f7';
(function (d, t) {
var ex; try {
var
gt = d.createElement(t), s = d.getElementsByTagName(t)[0], l = 'http' + ((location.protocol == 'https:') ? 's' : '');
gt.async = 'true'; gt.src = l + '://gadk.hit.gemius.pl/xlgemius.js'; s.parentNode.insertBefore(gt, s);
} catch (ex)
{ }
}(document, 'script'));
//end modified 2013-02-11 rjs as per user specs. updates on gemius
//--><!]]>
</script>
<script type="text/javascript">
var _sf_async_config = { uid: 17411, domain: "amino.dk" };
(function () {
function loadChartbeat() {
window._sf_endpt = (new Date()).getTime();
var e = document.createElement('script');
e.setAttribute('language', 'javascript');
e.setAttribute('type', 'text/javascript');
e.setAttribute('src',
(("https:" == document.location.protocol) ? "https://a248.e.akamai.net/chartbeat.download.akamai.com/102508/" : "http://static.chartbeat.com/") +
"js/chartbeat.js");
document.body.appendChild(e);
}
var oldonload = window.onload;
window.onload = (typeof window.onload != 'function') ?
loadChartbeat : function () { oldonload(); loadChartbeat(); };
})();
</script>
<!-- Visual Studio Browser Link -->
<script type="application/json" id="__browserLink_initializationData">
{"appName":"Chrome","requestId":"048073e31ed74ed68eeda96481c8bd4e"}
</script>
<script type="text/javascript" src="http://localhost:47739/1a675c31cef44fcca8dc0704a89a9da5/browserLink" async="async"></script>
<!-- End Browser Link -->
</body>
</html>
I am lost. I have been searching for hours now, and I cannot find that stupid JS that causes the postback. ANY ideas? It would be a tremendous help.
EDIT:
In the code, the startUpdate is refered. I tried to delete it, and I still got postback. Here is the code though:
function startUpdate(sender) {
if (tmr != null) clearTimeout(tmr);
tmr = setTimeout("updateSearch()", 700);
}
function updateSearch() {
tmr = null;
searchParams.transactiontype = $("input[name=transactionType]:checked").val();
searchParams.text = $("input[name=text]").val();
var sct = "";
$("input[name=sectors]:checked").each(function() { sct += $(this).val() + ","; });
searchParams.sector = sct;
searchParams.allsectorsrequired = $("#allSectorsRequired").attr("checked") == "checked" ? "true" : "";
var rgn = "";
$("input[name=regions]:checked").each(function() { rgn += $(this).val() + ","; });
searchParams.region = rgn;
var orgn = "";
$("input[name=operatingRegions]:checked").each(function() { orgn += $(this).val() + ","; });
searchParams.operatingregion = orgn;
searchParams.alloperatingregionsrequired = $("#allOperatingRegionsRequired").attr("checked") == "checked" ? "true" : "";
searchParams.priceFrom = $("input[name=priceFrom]").val();
searchParams.priceTo = $("input[name=priceTo]").val();
searchParams.yearFrom = $("input[name=yearFrom]").val();
searchParams.yearTo = $("input[name=yearTo]").val();
searchParams.canMove = $("input[name=canMove]:checked").val();
searchParams.financingavailable = $("input[name=financingAvailable]:checked").val();
searchParams.orderby = $("select[name=sortOrder]").val();
for (var key in searchParams) {
if ((!psp || psp[key] != searchParams[key]) && searchParams[key]) {
_gaq.push(['_trackEvent', 'Vbørs Søg autoupdate', key, searchParams[key]]);
}
}
psp = $.extend({}, searchParams);
$("#searchResults").load("@Url.Action("SearchJSON", "Search")", searchParams, searchCallback);
var tttxt = " til salg";
if (searchParams.transactiontype != 2) tttxt = " købes";
if (searchParams.text.length > 0) {
$("#searchtitle").text(searchParams.text + tttxt);
document.title = searchParams.text + tttxt;
}
}
Upvotes: 0
Views: 210
Reputation: 9348
Based on what I posted in the comments, somehow (you may know where this is happening in your code) your onchange
event handler is being changed, from startUpdate(this)
to top.location.href=sortLink.replace("{sortOrder}", this.value);
.
So, when the select
changes, it's replacing the page URL, which obviously cause a refresh (by GET).
Upvotes: 1