Search This Blog

Sunday, March 22, 2015

SharePoint Custom List with jQuery UI Autocomplete

<!doctype html>
<html lang="en">
    <meta charset="utf-8">
    <title>jQuery UI Autocomplete - Default functionality</title>
    <link rel="stylesheet" href="//">
    <script src="//"></script>
    <script src="//"></script>
    <link rel="stylesheet" href="/resources/demos/style.css">
    <script type="text/javascript">

        //We need to run our function only after sp.js file loads
        ExecuteOrDelayUntilScriptLoaded(ViewItem, "sp.js");
        function ViewItem() {

            var context = new SP.ClientContext.get_current();
            var web = context.get_web();
            var list = web.get_lists().getByTitle('City');

            //It will fetch all the items from the list
            var myquery = new SP.CamlQuery.createAllItemsQuery();
            myItems = list.getItems(myquery);

            //If the items load correctly then success function will be called
            context.executeQueryAsync(Function.createDelegate(this, this.success), Function.createDelegate(this, this.failed));

        function success() {
            var text = [];

            var ListEnumerator = this.myItems.getEnumerator();
            while (ListEnumerator.moveNext()) {

                //Will get the current row from the SP List
                var currentItem = ListEnumerator.get_current();

                source: text


        function failed(sender, args) {
            alert("failed. Message:" + args.get_message());
    <div class="ui-widget">
        <label for="tags">
        <input id="tags">


No comments:

Post a Comment