Permalink
Browse files

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

  • Loading branch information...
1 parent dab71f8 commit cbf7fb3d4e02d961020472271992fc5e5bb1d890 @andrewtobin committed Apr 8, 2012
Showing with 28 additions and 24 deletions.
  1. +1 −1 routes/index.js
  2. +2 −20 views/index.jade
  3. +3 −3 views/layout.jade
  4. +22 −0 views/typeahead-layout.jade
View
2 routes/index.js
@@ -1,3 +1,3 @@
module.exports = function (req, res) {
- res.render('index', { title: 'say wat?' });
+ res.render('index', { title: 'say wat?', layout: 'typeahead-layout' });
};
View
22 views/index.jade
@@ -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!')
View
6 views/layout.jade
@@ -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')
View
22 views/typeahead-layout.jade
@@ -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"
+ });
+ });

0 comments on commit cbf7fb3

Please sign in to comment.