Skip to content

Instantly share code, notes, and snippets.

@RainerBlessing
Created August 13, 2009 07:29
Show Gist options
  • Save RainerBlessing/167032 to your computer and use it in GitHub Desktop.
Save RainerBlessing/167032 to your computer and use it in GitHub Desktop.
/*
* jquery dialog - display the "OK" button in a disabled state
* removes the function from the button and adds the class "ui-state-disabled"
*/
if(data.length>0){
options="";
$.each(data, function(i, product){
if(product.product.id!=product_id){
options+= '<option value="'+product.product.id+'">'+product.product.name+'</option>';
}else{
options+= '<option value="'+product.product.id+'" selected="selected">'+product.product.name+'</option>';
}
});
$('#product_id').append(options);
$('#product_selection_dialog').dialog('option', 'buttons', {
"OK": function() {
selectedElement=$('#product_id :selected').text();
$("#product_name_"+$('#product_selection_dialog').attr("row_id")).text(selectedElement);
var id='#list_list_items_attributes_';
$(id+$('#product_selection_dialog').attr("row_id")+'_product_id').attr('value',$('#product_id').val());
$('#product_selection_dialog_button_'+$('#product_selection_dialog').attr("row_id")).attr('category_id',$('#product_category_id').val());
$(this).dialog("close");
},
Cancel: function() {
$(this).dialog("close");
}
}
);
}else{
$('#product_selection_dialog').dialog('option', 'buttons', {
Ok: function() { }
,
Cancel: function() {
$(this).dialog("close");
}
});
var okb=$('.ui-dialog-buttonpane button:last').prev();
okb.addClass('ui-state-disabled');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment