infinite scroll in Ionic not working - scroll

I am trying to implement infinite scroll however, it is not working. it keeps loading the same number of pages and doesn't load new pages. Id appreciate any help.
this is my controller :
$scope.getsomeinfo = function () {
$scope.isLoading = true;
$ionicLoading.show({
template: 'Loading ..'
});
info.getsomeinfo()
.then($scope.someinfo
, $scope.fjbfuirbf);
};
$scope. = function () {
var options = {};
= );
};

if I understand your code
this line
options.page = Math.ceil($scope.allDeals.count + 10 / 10);
should be
options.page = Math.ceil(($scope.allDeals.count + 10)/ 10);

if the attributes in defaultParams are correct (in the second call), so something like:
var defaultParams = {
mobileready: 1,
company_id: COMPANY_ID,
count: 10,
page: 2
};
could be a webservice problem?
Are you sure that /someinfo/info work as you intended?

Related

There was an unexpected failure with this assessment, invalid type provided

I'm attempting to run the following code which is pretty much copied from the OoTheBox UI Action called "View User's Response".
function showRiskAssessment(){
var ra = new GlideRecord('asmt_assessment_instance');
ra.addQuery('task_id', '=', current.sys_id);
ra.orderByDesc('taken_on');
ra.setLimit(1);
ra.query();
// var id = g_form.getUniqueValue();
var id = ra.sys_id;
//var type = g_form.getValue('metric_type');
var type = '468aeff2db9357008aeba9f7059619ca';
var url = 'assessment_take2.do?sysparm_assessable_sysid=' + id + '&sysparm_assessable_type=' + type + '&sysparm_reader_view=true';
var d = new GlideOverlay({
title: "User's Response",
iframe: url,
width:'80%',
height: '100%',
onAfterLoad: function() {
var iframe = d.getIFrameElement();
setTimeout(function(){
iframe.height = parseInt(iframe.height)+1;
},0);
}
});
d.render();
}
If I hardcode it like this it works. All I'm trying to do is on the change record I want to look up the most recent Assessment Instance for that particular change and display in the overlay. Obviously I can't hardcode the id however it seems the query isn't recognizing that info at all anyways.
function showRiskAssessment(){
// var ra = new GlideRecord('asmt_assessment_instance');
// ra.addQuery('task_id', '=', current.sys_id);
// ra.orderByDesc('taken_on');
// ra.setLimit(1);
// ra.query();
// var id = g_form.getUniqueValue();
var id = '5c516eeddb87d090ebce60ab1396198a';
//var type = g_form.getValue('metric_type');
var type = '468aeff2db9357008aeba9f7059619ca';
var url = 'assessment_take2.do?sysparm_assessable_sysid=' + id + '&sysparm_assessable_type=' + type + '&sysparm_reader_view=true';
var d = new GlideOverlay({
title: "User's Response",
iframe: url,
width:'80%',
height: '100%',
onAfterLoad: function() {
var iframe = d.getIFrameElement();
setTimeout(function(){
iframe.height = parseInt(iframe.height)+1;
},0);
}
});
d.render();
}
You're trying to use current.sys_id in a client side script. It is recommended to use g_form for client side scripts. You're also trying a GlideRecord on a client script, which is also not recommended.
To fix, replace:
ra.addQuery('task_id', '=', current.sys_id);
with:
var sysId = g_form.getUniqueValue();
ra.addQuery('task_id', '=', sysId);
Also, for the difference between g_form and current have a look here.

Problem with scope when inserting results of ajax call into page code

I have data returned from an Ajax call, but need to pass variables into or out of the Ajax onSuccess function to insert the results into my page. I'm pretty sure this is a scope problem.
I posted a complicated question here yesterday, mostly about the Ajax part of this, and that part is now working - I'm getting the results back correctly. I could insert it into my page code in two ways, but one involves getting a variable value out of the onSuccess function; the other needs to get a variable value into it! I can't make either of them work. Here's a stripped-down version of the code:
var base = 'http://10.0.1.2:90/~dvds/';
// initialization routines
document.observe ('dom:loaded', function() {
// set up handler for variable numbers of selects
var addselects = $$('.addselect');
for (var i = 0; i < addselects.length; i++) {
var addselect = addselects[i];
addselect.onchange = newSelect;
}
});
// handler for adding new field to array
function newSelect() {
var thisid = this.id;
var newhtml;
var url = base + 'ajaxtest';
// send request to do the business
var myAjax = new Ajax.Request (url, {
method: 'post',
onSuccess: function (req) {
var xml = req.responseXML;
var id = xml.getElementsByTagName('id')[0].firstChild.nodeValue;
if (id) {
newhtml = '\t\t<li>\r\t\t\t<select class="addselect" name="newlist" id="newlist" />\r\t\t\t\t<option value="" selected="selected"></option>\r';
// loop
var newid, newname;
var ids = xml.getElementsByTagName('id');
var names = xml.getElementsByTagName('name');
for (var i = 0; i < ids.length; i++) {
newid = ids[i].firstChild.nodeValue;
newname = names[i].firstChild.nodeValue;
newhtml += '\t\t\t\t<option value="' + newid + '">' + newname + '</option>\r';
}
newhtml += '\t\t\t</select>\r\t\t</li>\r';
// alert (thisid);
$('thisid').up('ul').insert (newhtml);
}
else {
alert (’ng');
newhtml = '<li>No good.</li>';
}
},
onFailure: function() {
alert ('Script failure.');
newhtml = '<li>No good.</li>';
}
});
// alert (newhtml);
// if (newhtml) {
// this.up('ul').insert (newhtml);
// }
}
Having established the variable thisid as this.id, I don't understand why $('thisid') doesn't work in the line $('thisid').up('ul').insert (newhtml); - especially as the value of thisid does show up correctly in the alert I've put in for testing (commented out). Why is this? If I put newhtml into that alert instead it's also correct.
And given that that seems not to work, I tried the alternative of passing the value of newhtml out (having declared it at the top) and inserting it in the page in the last block of code that's commented out - but that doesn’t work either.
Where am I going wrong?

jQuery Isotope - Issue with multiple filters

I try to use multiple filters inside portfolio-like page which uses Isotope.js. Please take a look at this page: http://decart-design.com/avancia-wp/vi-tilbyr/. Single filter works fine but not multiple filters don't :( Here's a piece of JS code I use:
jQuery('.filtering li').on('click', 'a', function(e) {
e.preventDefault();
if ( jQuery(this).parent().hasClass('selected') ) {
return;
}
var filters = {},
optionSet = jQuery(this).parents('.option-set');
jQuery(this).parent().parent().find('li').removeClass('selected');
jQuery(this).parent().addClass('selected');
var group = optionSet.data('filter-group');
filters[group] = jQuery(this).data('filter');
var isoFilters = [];
for ( var prop in filters ) {
isoFilters.push( filters[prop] );
}
var selector = isoFilters.join('');
var portfolioItems = jQuery(this).parent().parent().parent().parent().find('.filterable-items');
portfolioItems.isotope({ filter: selector });
console.log(selector);
return false;
});
For some reason (I don't why) but isoFilters.push( filters[prop] ); just doesn't work. After I click a second filter the items array just replaced with new value instead of adding it to this array. As you can see in console it just replaced with new value instead of adding it to the array. It's so strange...
Here's a working example from author's website: http://isotope.metafizzy.co/demos/combination-filters.html.
Could please someone help me to figure out what I make wrong?
Thank you in advance! Hope someone can help me to solve this problem.
Best regards,
Alex
I've found a way to solve this issue. Here's a proper code:
jQuery('.filtering li').on('click', 'a', function(e) {
e.preventDefault();
if ( jQuery(this).parent().hasClass('selected') ) {
return;
}
jQuery(this).parent().parent().find('li').removeClass('selected');
jQuery(this).parent().addClass('selected');
var isoFilters = [];
var elems = jQuery(this).parents('.filter-wrap').find('li.selected a');
jQuery.each(elems, function(i, e){
isoFilters.push(jQuery(e).attr('data-filter'));
});
var selector = isoFilters.join('');
var portfolioItems = jQuery(this).parent().parent().parent().parent().find('.filterable-items');
portfolioItems.isotope({ filter: selector });
console.log(selector);
return false;
});
Hope this will help someone who stuck with similar problem.

EmberJS 1.0.0 RC7 run code after images load

I'm trying to resize images after the view and images load on screen.
I have this TAG route and after update the EmberJS to RC7 I saw that the didInsertedElement stopped to work like before, it run one time only, but I need it to run every time I enter the view.
So I tried to run the code on setupController like this:
App.TagRoute = Ember.Route.extend({
model: function(params) {
return App.TKRPTumblr.findAll(params.tag);
},
setupController: function(controller, tag) {
if(typeof tag === 'object'){
controller.set('content', tag.response);
}else{
App.TKRPTumblr.findAll(tag)
.then(function(data) {
controller.set('content', data.response);
});
}
this.resizeView();
},
resizeView: function(){
var WIDTH = 0, RATIO, IMG, IMG_HEIGHT, IMG_WIDTH, FINAL_WIDTH, SIDEBAR_WIDTH = $('#sidebar').outerWidth(), MAX_WIDTH = $(window).width() - SIDEBAR_WIDTH, MAX_HEIGHT = $(window).height() - 125;
if($('html .post').find('img').length > 0){
$('.post').each(function(){
IMG = $(this).find('img');
IMG_WIDTH = IMG.attr('width');
IMG_HEIGHT = IMG.attr('height');
if(IMG_WIDTH > MAX_WIDTH){
RATIO = MAX_WIDTH / WIDTH;
IMG.width(MAX_WIDTH).height(IMG_HEIGHT * RATIO);
}
if(IMG_HEIGHT > MAX_HEIGHT){
RATIO = MAX_HEIGHT / IMG_HEIGHT;
IMG.width(IMG_WIDTH * RATIO).height(MAX_HEIGHT);
}
WIDTH += IMG.width();
});
if(isNaN(WIDTH)){
WIDTH = $('.post img').width() + SIDEBAR_WIDTH;
$('body').children('.ember-view').innerWidth(WIDTH);
}else{
WIDTH += SIDEBAR_WIDTH + 100;
$('body').children('.ember-view').innerWidth(WIDTH);
}
var evt = document.createEvent('Event');
evt.initEvent('_htmlReady', true, true);
document.dispatchEvent(evt);
}else{
Ember.run.next(this, function() {
this.resizeView();
});
}
}
});
Unfortunately it didn't worked as well :/ I can't figure out now how to do that :(( can anyone help me?
it run one time only, but I need it to run every time I enter the view.
If you rely on data returned by your model hook, then I guess you should rather use the routes afterModel hook, this is called every time you enter the route and the model is resolved.
App.TagRoute = Ember.Route.extend({
afterModel: function() {
this.resizeView();
}
...
});
But if you only care to invoke your function every time the route is entered no matter if the model is resolved or not, then using the routes activate hook is also an option:
App.TagRoute = Ember.Route.extend({
activate: function() {
this.resizeView();
}
...
});
Hope it helps.

Slideshow using Prototype and Scriptaculous

I wrote my first scriptaculous script to create a slideshow between some div element :
var SlideShow = Class.create({
initialize:function(element, delayStart){
this.element = element;
this.delayStart = delayStart;
this.slides = this.element.childElements();
this.numberOfSlides = this.slides.size();
this.numberActiveSlide = 1;
this.start_slideshow();
},
start_slideshow: function()
{
this.switch_slides.delay(this.delayStart);
},
switch_slides: function()
{
this.slides[this.numberActiveSlide].fade();
if (this.numberActiveSlide == this.numberOfSlides) { this.numberActiveSlide = 1; } else { this.numberActiveSlide = this.numberActiveSlide + 1; }
Effect.Appear.delay(this.slides[this.numberActiveSlide], 850);
this.switch_slides.delay(this.delay + 850);
}
});
document.observe("dom:loaded", function(){
var slideshows = $$('div.slideshow');
slideshows.each(
function(slideshow) {
s = new SlideShow(slideshow, 2);
});
});
But I always get this error and It's been hours I can't figure it out where my problem is!
Undefined is not an object (evaluating this.slides[this.numberActiveSlide]);
Thanks you !
Nick
99% sure it's a context issue. Make sure you bind your function calls so that this is retained throughout your code.
Debug what this is in switch_slides: it should be the same thing as this in start_slideshow. If it's not, bind your call to switch_slides to your instance:
start_slideshow: function()
{
this.switch_slides.bind(this).delay(this.delayStart);
},
You'll probably have to do the same in switch_slides where it calls itself.

Resources