Firing the Create Action manually when item is selected

2 posts, 0 answers
  1. Ryan Lege
    Ryan Lege avatar
    42 posts
    Member since:
    Sep 2008

    Posted 01 Oct 2012 Link to this post

    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
  2. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 04 Oct 2012 Link to this post

    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!
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top