JQuery Initialization on Listings Pages: Difference between revisions

From Littledamien Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
==Listings bindListingsHandlers()==
==Listings bindListingsHandlers()==
*<code>LITTLED.Listings.bindListingsHandlers(parent_selector)</code>
*<code>$('#listings-container').listings('bindListingsHandlers')</code>
*<code>parent_selector</code> targets the element containing the listings
*<code>$('#listings-container')</code> targets the element containing the listings. <code>#listings-container</code> is the most common element for this, but any appropriate selector can be specified.
*Inline edits: <code>.inline-edit-cell</code> double-click
*Inline edits: <code>.inline-edit-cell</code> double-click
*Pagination & paging button handlers (<code>.page-btn</code>)
*Pagination & paging button handlers (<code>.page-btn</code>)
Line 8: Line 8:
*Makes button icons for the following elements: <code>.details-btn</code>, <code>.preview-btn</code>, <code>.edit-btn</code>, <code>.print-btn</code>, <code>.update-cache-btn</code>, <code>.trash-btn</code>.
*Makes button icons for the following elements: <code>.details-btn</code>, <code>.preview-btn</code>, <code>.edit-btn</code>, <code>.print-btn</code>, <code>.update-cache-btn</code>, <code>.trash-btn</code>.
*Button element handlers should persist after listings content is refreshed.
*Button element handlers should persist after listings content is refreshed.
*<code>bindListingsHandlers()</code> in turn calles <code>bindListingsButtons()</code>. The two routines are separated so <code>bindListingsHandlers()</code> doesn't need to be called multiple times to avoid attaching duplicate handlers to listings elements.
*<code>$.listings('bindListingsHandlers')</code> in turn calles <code>$.listings('bindListingsButtons')</code>. The two routines are separated so <code>$.listings('bindListingsHandlers')</code> doesn't need to be called multiple times to avoid attaching duplicate handlers to listings elements.
*This routine does not refresh the handlers or buttons after the listings are refreshed. This can be achieved with
*This routine does not refresh the handlers or buttons after the listings are refreshed. This can be achieved with
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
$(document).ready(function() {
$(document).ready(function() {
LITTLED.Listings.bindListingsHandlers();
$('#listings-container').listings('bindListingsHandlers');
LITTLED.init({setSortables: LITTLED.Listings.bindListingsButtons});
LITTLED.init({setSortables: function() {
$('#listings-container').listings('bindListingsButtons');
}
});
});
});
</syntaxhighlight>
</syntaxhighlight>

Revision as of 17:43, 24 March 2012

Listings bindListingsHandlers()

  • $('#listings-container').listings('bindListingsHandlers')
  • $('#listings-container') targets the element containing the listings. #listings-container is the most common element for this, but any appropriate selector can be specified.
  • Inline edits: .inline-edit-cell double-click
  • Pagination & paging button handlers (.page-btn)
  • Update cache: .update-cache-btn click
  • Delete records: .trash-btn click
  • Makes button icons for the following elements: .details-btn, .preview-btn, .edit-btn, .print-btn, .update-cache-btn, .trash-btn.
  • Button element handlers should persist after listings content is refreshed.
  • $.listings('bindListingsHandlers') in turn calles $.listings('bindListingsButtons'). The two routines are separated so $.listings('bindListingsHandlers') doesn't need to be called multiple times to avoid attaching duplicate handlers to listings elements.
  • This routine does not refresh the handlers or buttons after the listings are refreshed. This can be achieved with
$(document).ready(function() {
	$('#listings-container').listings('bindListingsHandlers');
	LITTLED.init({setSortables: function() {
			$('#listings-container').listings('bindListingsButtons');
		}
	});
});

Keyword bindListingsHandlers()

  • LITTLED.Keyword.bindListingsHandlers(parent_selector)
  • parent_selector targets the element containing the listings
  • Loading inline editor: .edit-kw-btn click
  • Submitting and canceling inline edits: .kw-commit-btn and .kw-cancel-btn click
  • Button icons: .ui-icon-edit
  • bindListingsHandlers() in turn calles bindListingsButtons(). The two routines are separated so bindListingsHandlers() doesn't need to be called multiple times to avoid attaching duplicate handlers to listings elements.
  • Button element handlers should persist after listings content is refreshed.
  • The routine doesn't handle refreshing the button elements when the listings content is refreshed.

Keyword filter autocomplete

  • LITTLED.Gallery.keywordAutocomplete()

Datepicker

$('.datepicker').datepicker();

See Also