Thursday 9 April 2015

integration plug-ins - 2014-02-13

DataTables CDN files for DataTables integration plug-ins. Plug-ins repository last update date: 2014-02-13.

bootstrap

foundation

jPaginator

jqueryui

Tuesday 7 April 2015


Autocomplete :
$("#parentBranchName").autocomplete({
                source : function(request, response) {
                    $.ajax({
                        url : projectUrl + "/branchAutoComplete?branch=" + branchName,
                        type : "GET",
                        data : {
                            term : request.term
                        },
                        dataType : "json",
                        success : function(data) {
                            response($.map(data, function(item) {
                                console.log(item);
                                return {
                                    label : item.name,
                                    value : item.id,

                                };
                            }));
                        }
                    });
                },
                focus : function(event, ui) {
                    $("#parentBranchName").val(ui.item.label);
                    return false;
                },
                select : function(event, ui) {
                    event.preventDefault();
                    this.value = ui.item.label;
//                    $(this).next().val(ui.item.value);
                    $("#selectedParentBranchName").val(ui.item.label);
                    $("#parentBranchId").val(ui.item.value);
                    return false;
                }
            });
        })
Controller:
@RequestMapping(value = "/stationAutoComplete")
    public @ResponseBody List<Station> stationAutoComplete(@RequestParam(value = "stationName") String stationName) {
        return stationService.getAllStationIdAndNameByName(stationName);
    }
Dao:
public List<Station> getAllStationIdAndNameByName(String stationName){
        Query query = entityManager.createQuery("SELECT NEW Station (station.id, station.name) FROM Station station WHERE"
                + " (station.deleteIndicator = false) AND station.name LIKE :searchString");
        return (List<Station>) query.setParameter("searchString", "%"+ stationName +"%").getResultList();
    }

Sunday 5 April 2015

Autocomplete Example

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Autocomplete - Default functionality</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css"/>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.2.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.10.4/jquery-ui.min.js"></script>
<script>
$(function() {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$( "#tags" ).autocomplete({
source: availableTags
});
});
</script>
</head>
<body>
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags">
</div>
</body>
</html>

Want to learn more about the autocomplete widget? Check out the API documentation.

Autocomplete css themes CDN's