Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Scripts back to footer, using inheritance on layouts to do the typeahead

  • Loading branch information...
commit cbf7fb3d4e02d961020472271992fc5e5bb1d890 1 parent dab71f8
Andrew Tobin authored
2  routes/index.js
View
@@ -1,3 +1,3 @@
module.exports = function (req, res) {
- res.render('index', { title: 'say wat?' });
+ res.render('index', { title: 'say wat?', layout: 'typeahead-layout' });
};
22 views/index.jade
View
@@ -7,24 +7,6 @@ div.row-fluid
div.search
form(method='GET', action='/search')
div.span8
- input#q(type='text', name='q')
+ input#typeahead(type='text', name='q')
div.span3
- input.btn(type='submit', value='help!')
-script(type='text/javascript')
- $(document).ready(function() {
- $('#q').typeaheadAjax({
- source: function (typeahead, query) {
- return $.ajax({
- type: "GET",
- url: '/searchpartial',
- contentType: "application/json; charset=utf-8",
- dataType: "json",
- data: { q: query },
- success: function (data) {
- return typeahead.process(data);
- }
- });
- },
- property: "phrase"
- });
- });
+ input.btn(type='submit', value='help!')
6 views/layout.jade
View
@@ -7,9 +7,6 @@ html
link(rel='stylesheet',
href='http://fonts.googleapis.com/css?family=Cabin+Condensed:400,500,600,700')
link(rel='stylesheet', href='/stylesheets/app/main.css')
- script(type='text/javascript', src='/scripts/jquery-1.7.2.min.js')
- script(type='text/javascript', src='/scripts/bootstrap.min.js')
- script(type='text/javascript', src='/scripts/typeaheadajax.js')
body
div.container
div.container-fluid
@@ -22,3 +19,6 @@ html
a(href='/') Home
li
a(href='/about') About
+ block footer
+ script(type='text/javascript', src='/scripts/jquery-1.7.2.min.js')
+ script(type='text/javascript', src='/scripts/bootstrap.min.js')
22 views/typeahead-layout.jade
View
@@ -0,0 +1,22 @@
+extends layout
+
+block append footer
+ script(type='text/javascript', src='/scripts/typeaheadajax.js')
+ script(type='text/javascript')
+ $(document).ready(function() {
+ $('#typeahead').typeaheadAjax({
+ source: function (typeahead, query) {
+ return $.ajax({
+ type: "GET",
+ url: '/searchpartial',
+ contentType: "application/json; charset=utf-8",
+ dataType: "json",
+ data: { q: query },
+ success: function (data) {
+ return typeahead.process(data);
+ }
+ });
+ },
+ property: "phrase"
+ });
+ });
Please sign in to comment.
Something went wrong with that request. Please try again.