Git Product home page Git Product logo

jquery.ui.combobox.lazyload's Introduction

jQuery.UI.Combobox.Lazyload

This is an easy to implement tiny jQuery UI Widget that spawns a combobox that allows a user to search, select, from a select list, and lazyloads ajax calls against a query!

Example Code

Click Here

Implementation

$( document ).ready(function() {
	initializeComboBox('data.php', 'getItems', 'item_id', 'Select or type an item..');
	$( "#items" ).combobox();
});

initializeComboBox()

Parameter Description
path relative path to datasource file
method the invoked function in the file
html element html element that stores the current selection
placeholder text the default text that appears in the select input

To integrate a select element with this widget, insert this html markup:

<form action="./" id="searchForm" method="post">
	<input type="hidden" name="item_id" id="item_id">
	Item ID: 
	<select id="items" size="25">
	<option selected="selected">{item.LABEL}</option>
	</select>
</form>

The data that results from the Ajax call must be an array of objects, structured with these attributes, then delivered as a JSON. Your implementation may vary depending on language used:

// basic php example of the array of objects structure
<?php
	// this function name must match the name of the method above
	function getItems() {
		result = [];
		// when included in the array, selecting 0 will reset combobox to default state
		$obj = [];
		$obj["VALUE"] = 0;
		$obj["LABEL"] = "- None -";
		array_push($result, $obj);
		$obj["VALUE"] = 1;
		$obj["LABEL"] = "Item 1";
		array_push($result, $obj);
		$obj["VALUE"] = 2;
		$obj["LABEL"] = "Item 2";
		array_push($result, $obj);

		// ensure the header sent via Ajax is a JSON.
		header("Content-type:application/json");
		echo json_encode($result_array);
	}
?>

To filter the query results, use this GET variable:

term

jquery.ui.combobox.lazyload's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.