This is a migrated thread and some comments may be shown as answers.

Firing the Create Action manually when item is selected

1 Answer 39 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Ryan Lege
Top achievements
Rank 1
Ryan Lege asked on 01 Oct 2012, 11:15 AM
Basically, I have a bulleted list inside the listview, and when a user selects and item, I want it to automatically fire the create action method. And when the user deselects I want it to fire the Destroy action method

1 Answer, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 04 Oct 2012, 08:52 AM
Hi Benjamin,

 

Basically you should use the change event of the ListView to perform actions with the last and currently selected items when the event is fired. 

e.g.:

var lastSelectedItem;
 
function onChange(arg) {
    var currentSelectedItem;
    currentSelectedItem = this;
 
    if (!lastSelectedItem) {
        //First item selected
        lastSelectedItem = currentSelectedItem;
    }
    else {
        //lastItemSelected is unselected now
        //Make ajax call to the Destroy action
        //$.ajax({
        //    url: 'ajax/Destroy',
        //    success: function (data) {
        //        alert('Load was performed.');
        //    }
        //});
    }
 
    //Make ajax call to the Create action
    //$.ajax({
    //    url: 'ajax/Create',
    //    success: function (data) {
    //        alert('Load was performed.');
    //    }
    //});
 
    //save the currently selected item
    lastSelectedItem = currentSelectedItem;
}


Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
ListView
Asked by
Ryan Lege
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or