Jump to content

pkav

Members
  • Posts

    5
  • Joined

  • Last visited

pkav's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Ok I may have overlooked something regarding 'jqgrid', leave it with me. As you can see from then only test schedule i have its returning correctly, building the grid is just something I will have to read up on as im not familiar with it 0 // This is the only index being returned which is true index[0] Object { id="1", code="CAV", more...} id "1" code "CAV" flightnum "8783O" depicao "EIDW" arricao "KJFK" route "" route_details "" aircraft "B747-400" flightlevel "220" distance "2758.49" deptime "06:00" arrtime "12:00" flighttime "6" daysofweek "0" price "400" flighttype "P" timesflown "0" notes "" enabled "1" bidid "0" aircraftid "1" registration "897UJKJ" aircraft_minrank "0" aircraftlevel "0" depname "Dublin Airport" deplat "53.4213" deplng "-6.27007" arrname "Kennedy International" arrlat "40.6398" arrlng "-73.7787"
  2. Yep you need to create that table script or simply copy and paste from the admin one into wherever you are using the script, ie: schedules.tpl, correct? then change the following line url: '<?php echo actionurl('/schedules/schedulegrid');?>', {note: some of the admin functions wont work such as view schedule(id) and so on as those have not been created for the frontend} TO: url: '<?php echo actionurl('/schedules/getSchedulesJSON');?>',
  3. What version are you currently using? Also your php specs? [public] keyword is throwing an error which would maybe tell me the author has dis-abled them somehow(for your version of phpvms) or you are using an earlier version of php. I also noted "jsonp" is incorrect, "json" is required in this case, both are valid but for different methods. {note: might be 1 more typo, just got this new laptop and keyboard is driving me nuts, oh dear! } All of the above code is working.
  4. Add this is modules/Schedules.php public function getSchedulesJSON() { echo json_encode((object)SchedulesData::GetSchedules()); } Next If you use firebug or chrome tools you can add this snippet to index.tpl $(document).ready(function(){ $.ajax({ type : 'GET', url : '<?php echo actionurl("/schedules/getSchedulesJSON");?>', dataType : 'jsonp', success : function(results) { console.log(results); } }); }); The above code should return the JSON data, they should be indexed like so [0],[1],[2] and so on. Now you can mash all this data into one of the phpvms lib plugins you mention above. Or do a loop, whatever way you need it done $.each(result, function(index, stuff){}) Hope this makes sense.
  5. Recently I have been working on a VA for a client and I noticed im using quite a bit of jquery. Maintaining this code can be a bit of a headache so ive decided to create a boilerplate to maintain ALL my jQuery in one place. Before I began I done a quick search and was unable to find exactly what I wanted, there was a similar method used by studioforty9.com, however it relied on a body class produced by in their case magento e-commerce. This would not work in phpvms's case as it does not apply a class to the body for each page(controller) so here is my work-around for a global scope. The method: init Loads any code used cross domain initSiteSection Loads the correct code for certain controllers Firstly we catch the window.location.pathname Next we need to slice off anything before the last /{forward slash} Regex would work for this but I found lastIndexOf to be faster, then a substr and remove the last /{forward slash with +1} Finally we evaluate the code{when a controller is loaded, we pick it up and then apply the correct initFunction to that controller} Our code is now easy to maintain .... (function($){ var Iphpvms = { sections: { 'profile' : 'this.initProfile()', 'pilots' : 'this.initPilots()', 'pireps' : 'this.initPireps()', 'downloads' : 'this.initDownloads()', 'schedules' : 'this.initSchedules()', 'finances' : 'this.initFinances()' }, /* init ################################################################### */ init: function(){ //Common functionlaity across your site }, /* initSiteSection ######################################################### */ initSiteSection: function(section){ var path = window.location.pathname; var index = path.lastIndexOf("/"); var section = path.substr(index +1); eval(this.sections[section]); /** * If a class is applied to the <body> for each page(controller) * you can use this method instead! * Source: studioforty9.com * initSiteSection: function(section){ var section = $('body').attr('class').split(' ')[1]; eval(this.sections[section]); }, **/ }, /* initProfile ######################################################### */ initProfile: function(){ //De-buggin ONLY console.log($('body').attr('class', 'profile')); }, initPilots: function(){ //De-buggin ONLY console.log($('body').attr('class', 'pilot')); }, /* initPireps ######################################################### */ initPireps: function(){ //De-buggin ONLY console.log($('body').attr('class', 'pireps')); }, /* initDownloads ######################################################### */ initDownloads: function(){ //De-buggin ONLY console.log($('body').attr('class', 'downloads')); }, /* initSchedules ######################################################### */ initSchedules: function(){ //De-buggin ONLY console.log($('body').attr('class', 'schedules')); }, /* initFinances ######################################################### */ initFinances: function(){ //De-buggin ONLY console.log($('body').attr('class', 'finances')); }, } /* Ready? Invoke######################################################### */ $(function() { Iphpvms.init(); Iphpvms.initSiteSection(); }); // use jQuery.noConflict() so we can use with other frameworks })(jQuery.noConflict());
×
×
  • Create New...