i have delete view in pyramid , i'm using mako templates , knockout js.
config.add_route('delete', '/delete/{id}') this route delete view in pyramid. want bind buttons in template url invokes delete view.
i've tried doing as:
<script> this.delete = function(detail){ $.post( "${request.route_url('delete', id=detail['id'])}", {'action' : 'delete', 'id' : detail.id()}, function(response){ //remove selected detail array self.details.remove(detail); } ); }; however returns following traceback:
typeerror: 'undefined' object has no attribute '__getitem__' - what correct way of doing this?
- the
deleteview haslocationset current page. there way without refreshing current page?
okay, got answer. i'm adding future googlers.
the values must made observable ko.observable('<some_value>') in knockout model updated without refreshing.
the link should have been delete/<some_id>. concatenate strings "delete/" , id json object as:
var delete_link = "delete/".concat(detail.id);
then use delete function follows:
this.delete = function(detail){ var delete_link = "delete/".concat(detail.id); $.post( delete_link, {'action' : 'delete', 'id' : detail['id']}, function(response){ self.details.remove(detail); } ); };
Comments
Post a Comment