PDA

View Full Version : Delete without redirect ??



Rushleader
8 Jun 2009, 5:15 AM
Hey everyone ,

ive got a little question , Is it possible to delete some table by just calling an Action ?

Something like an onClick calling an Action without redirecting to the page , because im just going to reload the store its in.

Well ,

thanks anyway

Rushleader

jay@moduscreate.com
8 Jun 2009, 5:29 AM
what type of 'table'? Database/DOM Element ?

Rushleader
8 Jun 2009, 5:40 AM
Well , im loading the store together with json , so i dunno for sure.
you can see for yourself




function deleteMes(val){


deleteMsg();




function deleteMsg(){


Ext.Msg.show({

title:'Delete',

msg: 'Are you sure you want to delete this item ?',
width: 325,
buttons: Ext.Msg.YESNO,
icon: Ext.MessageBox.WARNING,
fn: confDelete,
modal: true,
closable: false,
resizable: false,
draggable: false
});
}









function confDelete(btn){




if(btn == 'yes')


{

//window.location = '../../guestbook/admin_guestbook/delete/id/' + val ;



Ext.getCmp("grid").getStore().load();



} else {


Ext.getCmp("grid").getStore().load();




}

}







}



This is the delete function,

its being called by an onclick :



function render_pagina_actions(val, x, store){

var rc = "";


rc += "<a href=\"#\" onclick='deleteMes("+val+")<?php echo $this->deleteButton(false); ?>";



rc += "<a href=\"#\" onclick='editMes("+val+")'><img src='<?php echo $this->templateUrl; ?>/images/icons/edit.png'></a>";

return rc;
}


with a json store like this :




var store = new Ext.data.GroupingStore({


url: '<?php echo $this->baseUrl; ?>/guestbook/admin_guestbook/json',



sortInfo: {field: 'title', direction: "DESC"},


reader: new Ext.data.JsonReader({


root: 'items',


id:'id',


totalProperty: 'totalCount'


},[


{name: 'id'},


{name: 'title'},


{name: 'body'},


{name: 'author'},


{name: 'created_at'},


{name: 'modified_at'}


]

)
});

jay@moduscreate.com
8 Jun 2009, 5:51 AM
i can't help you if you don't know what you're asking for

Rushleader
8 Jun 2009, 5:56 AM
Well what i want to do is this :

I want to call my delete action without using that ugly window.location because i dont want it to redirect.

and since i cant find any normal way to do that =.= i thougth i'd ask

well thanx anyway,

Rushleader

jay@moduscreate.com
8 Jun 2009, 6:18 AM
Ext.Ajax.request() look it up in the wiki

Rushleader
8 Jun 2009, 6:45 AM
Hey thanks mate ,





Ext.Ajax.request({
url: '../../guestbook/admin_guestbook/delete/id/' + val,
method: 'POST'
})

Ext.getCmp("grid").getStore().load();



This is what came out of it :) worked out great ! :D

Thanks alot
Rushleader