eldarion/bootstrap-ajax — pull request #23 by stevenmhunt (2013-01-18 13:27:04+00:00)
Title: Fix for integration with spinner.

A friend of mine told me about your project and wanted to use it on his site. It's very cool, and as you said it eliminates the need to write the same 20 lines of code over and over again. However, the problem we ran into was that the spinner would get stuck and would blow away the contents of the

. Everything works fine if we don't include the spinner library in the page. So, I dug into the code and made some modifications:

* The spinner will be rendered inside of a

with class ajax-spinner so that we can find it later using a jQuery selector.
* I changed the behavior of the spinner if the developer does not specify a place for the spinner to render using the data-spinner or similar attribute. It still renders inside of the selected element by default, but it does not clear the contents of the tag; I found it unexpected that it would do that unless I explicitly told it to do that.
* When data has completed loading or there has been an error, the code locates the

inside of the selected element using the selector ".ajax-spinner" and removes it.
* I also included a demo with static data to demonstrate that the spinner integration works correctly.