Here is my chunk of code:
var update_shipping_methods = function(methods) {
$(methods).each( function(i) {
$('div$methods img#shipping_loader').remove();
var p = document.createElement('p');
var s = this.name + ' ' + this.rate;
var i = $(document.createElement('input'))
.attr('id', this.id)
.attr('type', 'radio')
.attr('name', 'checkout[shipment_attributes][shipping_method_id]')
.val(this.id)
.click(function() { $('div#methods input').attr('checked', '');
$(this).attr('checked', 'checked'); });
if($(methods).length == 1) {
i.attr('checked', 'checked');
}
var l = $(document.createElement('label'))
.attr('for', this.id)
.html(s);
$('div#methods').append($(p).append(i).append(l));
});
$('div#methods input:first').attr('validate', 'required:true');
return;
};
the line: var s = this.name + ' ' + this.rate; is where I need the if statement. Basically "this" is a shipping name and rate. I need to write an if statement that basically removes the this.rate if "some rails code"
So if "some rails code"; var s = this.name; else var s = this.name + ' ' + this.rate; end
Does that make sense? Any thoughts?