Advertisement
Guest User

Untitled

a guest
Apr 9th, 2020
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. listStreamWithTabsPage.methods.renderHeader = function($header){
  2.     // core vars
  3.     var self = this,
  4.         page = this._getPage(),
  5.  
  6.     // use vars
  7.     var title = self.getTitle() || page.route.query.title,
  8.         description = 'Risus nullam eget felis eget. Donec enim diam vulputate ut pharetra sit. Sem integer vitae justo eget. Eget nunc scelerisque viverra mauris in. Viverra suspendisse potenti nullam ac tortor vitae. Cursus turpis massa tincidunt dui ut ornare lectus sit. Viverra accumsan in nisl nisi scelerisque.',
  9.         tabChoices = [
  10.             {id : 1, text: 'Opción 1'},
  11.             {id : 2, text: 'Opción 2'},
  12.             {id : 3, text: 'Opción 3'}
  13.         ];
  14.  
  15.     // tempalte con titulo, descripción opcional y un tabs
  16.     var templateHtml = `
  17.         <div class="form-header">
  18.             <div class="ms-Form-Title">` + title +  `</div>
  19.             <div class="ms-Form-Description">` + description + `</div>
  20.             <div class="segmented" style="margin:20px auto; max-width:600px">
  21.                 <a class="button" segment-id="` + tabChoices[0].id + `" segment-text="` + tabChoices[0].text + `">` + tabChoices[0].text + `</a>
  22.                 <a class="button" segment-id="` + tabChoices[1].id + `" segment-text="` + tabChoices[1].text + `">` + tabChoices[1].text + `</a>
  23.                 <a class="button" segment-id="` + tabChoices[2].id + `" segment-text="` + tabChoices[2].text + `">` + tabChoices[2].text + `</a>
  24.             </div>
  25.         </div>
  26.     `;
  27.  
  28.     // agregar html
  29.     $header.html(templateHtml);
  30.  
  31.     // agregar al hacer click sobre botón
  32.     $header.find('.segmented .button').on('click', function(e){
  33.         var choice = this.getAttribute('segment-text'),
  34.             query = '<Eq><FieldRef Name="Opciones" /><Value Type="Choice">' + choice + '</Value></Eq>';
  35.  
  36.         // manejar lógica para ver botón seleccionado
  37.         $header.find('.segmented .button').removeClass('button-active');
  38.         $(this).addClass('button-active');
  39.  
  40.         // self.requestItems() acepta como parametro una consulta CAML
  41.         self.requestItems(query);
  42.     });
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement