Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

radio.js 09 Jul 2013 06:43 #7924

  • VeCrea
  • VeCrea's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
The radio.js in /administrator/your_coook_component/dom/assets/bootstrap/js/radio.js doesn't do its job as i would like him to do.
It works fine if there's only two choices (boolean, shows green button when you click on Yes, red button when you click on No)
But if you have more choices, like an enumeration field that is configured to display as Radio, then it all falls appart : the last button becomes green when clicked (because it's related to the 1 of the boolean i guess), but other buttons receive btn-undefined as class.
Here is my version of radio.js : i loose red/green in boolean (choice i make is always green), but it works with everything i throw at him.
(function($){
	var colors = {'':'primary','0':'danger','1':'success'};
	$('document').ready(function(){
		$(".btn-group label").click(function() {			
			var label = $(this);
			var input = $('#' + label.attr('for'));
			if (!input.prop('checked')) {
				label.closest('.btn-group').find("label").removeClass('active'
					+	' btn-' + colors['']
					+	' btn-' + colors['0'] 
					+	' btn-' + colors['1']);
				
				//label.addClass('active btn-' + colors[input.val()]);
				label.addClass('active btn-success');
				input.prop('checked', true);
			}
		});
		$(".btn-group input[checked=checked]").each(function() {
			//$("label[for=" + $(this).attr('id') + "]").addClass('active btn-' + colors[$(this).val()]);
			$("label[for=" + $(this).attr('id') + "]").addClass('active btn-success');
		});
	});
})(jQuery);

Please Log in or Create an account to join the conversation.

radio.js 29 Jul 2013 10:50 #10617

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Fixed.
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.077 seconds

Real time saver and great Component Builder tool ! I have been developing with J-Cook Pro Component Builder for several months now and can say with all honesty that this product/service is second to none. The product is feature rich and is being improved and added to all the time. Do yourself a favor if you need to build a Joomla! Component then you can do no wrong in trying the product. You will save on time and effort while being able to deliver your project on time. J-Cook pro does the hard work for you you then have the freedom to fully customise the end result for your own needs. 

One word: Awesome.
Edwardcox (JED)
         

Get Started