Improve the default widget #3

Merged
merged 2 commits into from Nov 28, 2011

Conversation

Projects
None yet
2 participants
Contributor

timheap commented Nov 28, 2011

The default widget has numerous problems, including:

  • Unnecessary duplication of JavaScript code,
  • Failure to work without JavaScript, and
  • Bugs when multiple widgets are included on the same page

I fixed these issues by:

  • Turning the JavaScript code in to a jQuery plugin, removing most of the initialization code from the individual widget templates to a external JavaScript file, and adding a {% phileo_js %} tag to load this plugin.
  • Giving each like button a unique ID, so multiple like buttons can appear on a single page
  • Made the widget a plain old form. This way, it works without JavaScript. Additionally, the CSRF stuff is included in the form by default, so the ajax_csrf.js script is obsolete
Tim Heap Reworked the widget form, including the JavaScript
- Turned the JavaScript code in to a jQuery plugin, removed most of the
  initialization code from the individual widget templates to a external
  JavaScript file, and added a {% phileo_js %} tag to load this plugin.
- Each like button gets a unique ID, so multiple like buttons can appear
  on a single page
- Made the widget a plain old form. This way, it works without
  JavaScript. Additionally, the CSRF stuff is included in the form by
  default, so the ajax_csrf.js script is obsolete
45b5c41
Tim Heap Add a default value for widget_id
The widget_id when rendering a like widget defaulted to None, which
broke the widget when no id was supplied. This creates a default id for
widgets, which should be unique for that model instance.

Conflicts:

	phileo/templatetags/phileo_tags.py
012eab3

@paltman paltman added a commit that referenced this pull request Nov 28, 2011

@paltman paltman Merge pull request #3 from maelstrom/better-form
Improve the default widget
4a323a2

@paltman paltman merged commit 4a323a2 into pinax:master Nov 28, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment