Skip to content

Commit

Permalink
Stopping the event
Browse files Browse the repository at this point in the history
Request is run only if library_id is chosen - otherwise error is displayed
Input field is cleaned after successful action
  • Loading branch information
zalun committed Nov 12, 2010
1 parent 29e6586 commit 93bda3f
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions apps/jetpack/media/js/Package.js
Expand Up @@ -577,24 +577,32 @@ Package.Edit = new Class({
}).send();
},
assignLibraryAction: function(e) {
e.stop();
// get data
library_id = $(this.options.assign_library_input).get('value');
// assign Library by giving filename
this.assignLibrary(library_id);
},
assignLibrary: function(library_id) {
new Request.JSON({
url: this.assign_library_url || this.options.assign_library_url,
data: {'id_number': library_id},
onSuccess: function(response) {
// set the redirect data to edit_url of the new revision
fd.setURIRedirect(response.edit_url);
// set data changed by save
this.setUrls(response);
//fd.message.alert('Library assigned', response.message);
this.appendLibrary(response);
}.bind(this)
}).send();
if (library_id) {
new Request.JSON({
url: this.assign_library_url || this.options.assign_library_url,
data: {'id_number': library_id},
onSuccess: function(response) {
// clear the library search field
$(this.options.assign_library_input).set('value','');
$(this.autocomplete.options.display_el).set('value','');
// set the redirect data to edit_url of the new revision
fd.setURIRedirect(response.edit_url);
// set data changed by save
this.setUrls(response);
//fd.message.alert('Library assigned', response.message);
this.appendLibrary(response);
}.bind(this)
}).send();
} else {
fd.error.alert('No such Library', 'Please choose a library from the list');
}
},
appendLibrary: function(lib) {
var html='<a title="" id="library_{library_name}" href="{library_url}" target="{id_number}" class="library_link">'+
Expand Down

0 comments on commit 93bda3f

Please sign in to comment.