www.webdeveloper.com
Results 1 to 2 of 2

Thread: jqTransform radio button problem

  1. #1
    Join Date
    Jul 2012
    Posts
    2

    jqTransform radio button problem

    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

    Code:
    <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

    Code:
    $(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);	
    }

  2. #2
    Join Date
    Jul 2012
    Posts
    2
    Hi,

    I still havent found a proper solution to this. To specify my problem a little bit more. Since I am using the jQuery lib jqTransform to style my form, the code $("input[id=" + ci + "]").prop("checked", true); (in step 2 in my original post) is overrided by jqTransform and the radiobutton that I try to select in the code example is not selected (or checked if you want). What I am looking for is the corresponding jqTransform solution how to select a radiobutton from jQuery/JS. Now anyone?

    /Titoos

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles