
Untitled
By: a guest on
May 30th, 2012 | syntax:
jQuery | size: 1.36 KB | hits: 25 | expires: Never
$( function() {
$( '.add_to_collection' ).click( function() {
$( this ).hide();
$( '#element_collections' ).show( 'slow' );
return false;
});
$( '#element_collections' ).submit( function() {
var form_data = $( this ).serialize();
console.log( form_data );
$.ajax({
context: this,
url: root_url + '?act=siteuser/add_to_collections',
type: 'POST',
dataType: 'json'',
data: form_data,
success: function( response ) {
console.log( response );
if ( response.status == true ) {
$( this ).find( 'input[type=checkbox]:checked' ).attr( 'disabled', true );
if ( response.new == true ) {
var new_element = $( '<input type="checkbox" id="collection' + response.collection_id + '" value="' + response.collection_id + '" name="collection_rel[]" checked="checked" disabled="disabled">' +
'<label for="collection_' + response.collection_id + '">' + response.collection_name + '</label>' );
$( '.collections_assign' ).append( new_element );
$( '#element_collections input[name=collection_name]' ).val( '' );
$( '#element_collections textarea' ).val( '' );
}
$( this ).hide( 'slow', function() {
$( '.add_to_collection' ).show();
});
}
}
});
return false;
});
});