javascript

Fixing a node reference autocomplete field

Occasionally a node reference or entity reference autocomplete widget will not operate as expected, specifically when it is based off a view reference display. Other widgets, the select box, or list of checkboxes, will still function correctly.

If you use jQuery in development, you've almost definitely used $(document).ready(). $(document).ready() is a wonderful function that lets you run Javascript code as the page is ready to handle it. But one potentially frustrating aspect of it is that functions are executed in the same order they're passed in, and jQuery doesn't let you choose which functions run first.

Usually, this is fine, but every once in a while, you really want your function to run before another function. For example, if your page is running jCarousel or Google Maps, or any other library that changes the markup of your page, you might want to do some processing before they get a chance. With the traditional $(document).ready(), you'd be out of luck.

jQuery comes with a lot of functionality right out of the box, and even more in the form of plugins, but sometimes you run into situations where the function you want doesn't exist. Or maybe you just want to create a shortcut for a set of functions you use often. Maybe you even want to write your own jQuery plugin, but you aren't sure where to begin. For these situations, jQuery comes with a handy shortcut for adding functions, jQuery.fn.

Pages

Subscribe to RSS - javascript
Twitter icon
Facebook icon
Flickr icon