We have a listview bound to a collection of images. It's set to single select. We handle onChange() to get the name of the image file and write this to a textfield (id = "ImageFile"):
function onChange(arg) {
var selected = $.map(this.select(), function (item) {
return $(item).text();
});
$("#ImageFile").val(selected[0].trim());
}
In order to effectively cancel the selection we provide a hyperlink (id="clearImage") next to the text field and handle it's click method:
// clears the value in the Image text field
$("#clearImage").bind("click", function (e) {
e.preventDefault();
$("#ImageFile").val("");
});
Is there a way to clear the listview of any selection (the orange background) from clearImage.click() ?
Alternatively can the second click of a selected item in the listview deselect it? A toggle() type function that will select/deselect?
Is there a function to pre-select an item in the listview? So on an Edit record screen I would select the item in the listview as it is loaded that the user selected on the Add screen of the record?
Hoping we can get rid of the ImageFile text field and handle select/deselect in the ListView itself.
Thank you,
Simon