Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Filter the timeline on keyword search.
- */
- Drupal.behaviors.filterOnKeywords = {
- attach: function (context, settings) {
- var keywordsField = $('#sixteen-timeline-filters-form input[name="keywords"]');
- keywordsField.keyup(function (event) {
- var keywordsValue = keywordsField.val().trim();
- if (keywordsValue.length > 2) {
- // Wait a 1,5 seconds before calling the AJAX function.
- delay(function() {
- $.ajax({
- url: '/timeline-keyword-search/ajax/' + keywordsValue,
- data: null,
- success: function (data) {
- // data[0] are basic settings, data[1] is de actual data.
- var newContent = data[1].data;
- var wrapper = data[1].selector;
- $(wrapper).replaceWith(newContent);
- $(window).trigger('resize');
- }
- });
- }, 1500);
- }
- });
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement