Patternslib / Patterns

Library for quickly applying rich interaction patterns without the need to write any JavaScript.
http://patternslib.com
Other
104 stars 43 forks source link

Feature: pat-inject event on no feedback from server #372

Closed cornae closed 10 years ago

cornae commented 10 years ago

Sometimes there's no feedback at all from the server when using AJAX with pat-inject. It would be convenient to get an event when this is the case. A webdesigner/developer may then attach a certain behaviour such as a custom designed error message to this event.

cornae commented 10 years ago

@frontendplace , Does the above cover the problem space?

wichert commented 10 years ago

I suspect we can just enable jQuery global AJAX events for injection. Is there any reason that won't be sufficient?

frontendplace commented 10 years ago

At this time on 'no response', source or target not found only a log is registered in the console but no event is fired. it would be convenient if an event is fired and we could add an event handler on these events so we could display an error message and remove the inject class and can inform the user when the server responded different than expected. This is useful when you use an external service where you don't have access to the response sources. If an error occurred and no other response is expected the inject class must be removed. ( maybe as option)

wichert commented 10 years ago

Looking at the code I notice several things:

It would be nice if the pat-ajax-error and pat-ajax-success events used a proper jQuery.Event object, but even right now they should already be usable.

frontendplace commented 10 years ago

if the source or target is not inside the response is there an event too? What I understand when I don't get a response I can use a listener to pat-ajax-error. when we get 500 or 503 error back do we get an pat-ajax-error back then too or success with source not found?

wichert commented 10 years ago

This ticket is about a generic server error, ie the XHR request failing. Looking at the source that is already covered: if the server responds with an error (and HTTP status codes 5xx or 4xx are errors) that will trigger the pat-ajax-error event.

Errors regarding either the content of the response or not finding the injection point in the DOM are covered in issue #373.

frontendplace commented 10 years ago

great thanx