I wrote a method as follows:
detectNameConflict: function() {
var existing_filenames = this.element.find('ul.existing_files > li');
if (existing_filenames.length > 0) {
var try_name = this.element.find('div.target_filename').text().trim();
existing_filenames.each(function(index, el) {
if ($(el).text() == try_name) {
return "contain_conflict";
}
});
} else {
return "no_conflict";
}
},
This code doesn't work, because it always returns "no_conflict", even when there is a naming conflict.
note: this.element
is from jQueryUI widget factory. It refers to the DOM element on which the widget instance attached.