Hi all,
I have a problem related to the jQuery plugin jqTransform. When it’s used together with the library jQuery BBQ I cant seem to get my form back to the expected state when hitting the browser back button. I use jQuery BBQ to manage the behavior of my site when the end user clicks on the browser back button. Depending on the values in the hash part of the URL one specific radio button is to be selected. So, I always 1) reset the form and 2) dynamically update the form according to the hash values. However, trying to select a radiobuttin in step 2 above, jqTransform seems to override the expected behavior. Selecting a radio button via click on the actual page works fine though.
I can surely need some help on this one. How can I ask jqTransform to select the radio button? Suggestions?
Stripped code example below.
/Titoos
HTML
<form name="filterform" class="jqtransform" action="#" method="POST">
<input type="radio" id="101" name="cid" value="" /><label>101</label>
<input type="radio" id="102" name="cid" value="" /><label>102</label>
</form>
JS
$(function(){
$("input[name=ci]").click(function() {
handlehash('ci', $(this).attr("id"));
});
$(window).bind('hashchange', function(e) {
// 1. Reset form
$("input[name=ci]").removeAttr("checked");
// 2. Update form
var hashobj = $.bbq.getState();
if(hashobj["ci"] != null) {
var ci = hashobj["ci"];
$("input[id=" + ci + "]").prop("checked", true);
}
})
$(window).trigger( 'hashchange' );
});
function handlehash(k, v) {
var hashobj = $.bbq.getState();
hashobj [k] = v;
$.bbq.pushState(hashobj);
}