Web-dev newbie reporting in:
I'm writing my first mobile app using jquery mobile and currently stuck there:
For some additional functionality, I would like to get url of current active page. I found out that it can be done using $.mobile.activePage . For example, following code works as expected for me:
$(document).on("pagecreate",function(){
console.log($.mobile.activePage[0].baseURI);
});
However, when I press "back" button, Uncaught TypeError: Cannot read property 'activePage' of undefined appears in console and app hangs.
Question: how do I handle this situation? Thanks!
You should do this a little bit different, use this code:
$(document).on("pageshow",'.ui-page',function(){
console.log($.mobile.activePage[0].baseURI);
});
Working example: http://jsfiddle.net/Gajotres/vds2U/82/
Related
actually I have a really weird problem, that I have been trying to solve for two weeks.
to begin with, I am using sharePoint 2010. we created two dashboards that fetch information from lists and then display them in a graphical form, simply the javaScript script using AJAX get the list and then use the information. its worth mentioning that I am using Jquery
here is a picture of what I am talking about:
lets say this is dashboard1
is working like a charm in all browser even internet explorer
the problem is with another dashboard, dashboard2,
the problem with dashboard2 is that, a jquery problem as I copied from the console:
Critical Error: Object doesn't support this property or method addeventlistener
to get what I mean, the navigation bars on the right get its html from the list that I fetch and I use jquery and bootstrab for collapse , this is how the not working page looks like:
the navigation bar doesn't get its items, the graphs don't load
I have tried this fix but it didn't work.
what I suspected is that, this problem is related to sharePoint somehow,let me tell you what else I have tried, I made another copy of the index.html which is the main index page for dashboard1 the working dashboard, and I called it test.html which has exactly the same code, its supposed to work right ? because this is just a copy of the index.html that is working in internet explorer and all browsers, but surprisingly it didn't work and I got the same error that I got when I run the other index2.html the one for the other dashboard (dashboard2).
what can cause this problem? and fixes can I try? Its nothing related to the code ( I can share the code if you want) but its a bug related to sharepoint or Microsoft explorer or both !
Critical Error: Object doesn't support this property or method addeventlistener
So first I have read this Stack Overflow question and it doesn't look like my same issue.
Basically I'm trying to use Mocha and Zombie.js to run some tests on my Node.js site.
I'm trying to check to see if I can create a user. In the end I would like to check to see if my bootstrap modal exists. Basically I have the bootstrap modal wrapped in an EJS if statement so there is defiantly a chance it might not exist. So that is why I'm trying to run tests on it.
But currently it's not even working with browser.assert.success(); so I'm currently just trying to solve this before moving on to checking for elements.
browser.visit('/login', function() {
browser.fill('email', 'test1#test.com');
browser.fill('password', 'testtest');
browser.pressButton('Login').then(function() {
browser.assert.success();
}).then(done, done);
});
In this case I should be running the following code on the page the browser is currently on.
<script>
$("#paymentModal").modal('show');
</script>
When running this unit test it gives me the following error.
https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js:3
}return c}function Q(a){var b;for(b in a)if(("data"!==b||!n.isEmptyObject(a[b]))&&"toJSON"!==b)return!1;return!0}function R(a,b,d,e){if(M(a)){var f,g,h=n.expando,i=a.nodeType,j=i?n.cache:a,k=i?a[h]:a[h]&&h;if(k&&j[k]&&(e||j[k].data)||void 0!==d||"string"!=typeof b)return k||(k=i?a[h]=c.pop()||n.guid++:h),j[k]||(j[k]=i?{}:{toJSON:n.noop}),"object"!=typeof b&&"function"!=typeof b||(e?j[k]=n.extend(j[k],b):j[k].data=n.extend(j[k].data,b)),g=j[k],e||(g.data||(g.data={}),g=g.data),void 0!==d&&(g[n.camelCase(b)]=d),"string"==typeof b?(f=g[b],null==f&&(f=g[n.camelCase(b)])):f=g,f}}function S(a,b,c){if(M(a)){var d,e,f=a.nodeType,g=f?n.cache:a,h=f?a[n.expando]:n.expando;if(g[h]){if(b&&(d=c?g[h]:g[h].data)){n.isArray(b)?b=b.concat(n.map(b,n.camelCase)):b in d?b=[b]:(b=n.camelCase(b),b=b in d?[b]:b.split(" ")),e=b.length;while(e--)delete d[b[e]];if(c?!Q(d):!n.isEmptyObject(d))return}(c||(delete g[h].data,Q(g[h])))&&(f?n.cleanData([a],!0):l.deleteExpan
TypeError: j.getClientRects is not a function
at k (https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js:3:26891)
at Object.n.extend.pixelMarginRight (https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js:3:25936)
at a.getComputedStyle.Sa (https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js:3:27592)
at Function.n.extend.css (https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js:3:30895)
at https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js:4:520
at Y (https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js:3:4661)
at n.fn.extend.css (https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js:4:361)
at c.setScrollbar (http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js:6:18612)
at c.show (http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js:6:14692)
at .<anonymous> (http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js:6:13878)
Looks to me like for some reason Zombie.js isn't loading jQuery on that page or there is an error. But in that previous Stack Overflow question and answer at the beginning of the question it looks like Zombie.js can load jQuery.
Are you not able to load jQuery with Zombie.js? How can I fix this? Seems like a very simple thing to test pages with jQuery. Any ideas?
Let me know if you need any additional information or anything. Thanks.
EDIT for some reason when downgrading to jQuery version 1.11.3 it seems to work and the error goes away. Any reason for this?
This bug is fixed : https://github.com/assaf/zombie/issues/1031
Adopting jsdom 8/9 as the fix for your problem was harder than I
wanted. It should be pretty easy to add a dummy implementation for
getClientRects() just to get past that specific failure. I'll try that
and see how it goes
Add a stub implementation of getClientRects() was straightforward. I've published 5.0.1 with a fix for this specific failure.
mdlavin
I have code for a no longer supported map marker form.
It works fine on jquery-1.6.1.min.js (its original).
What I want is for it to work on jquery-1.11 (the webpage I need it to work on depends on this, I cannot fall back).
What The Issue Is:
If try to use the form it successfully sends the message but the issue is it opens the 'acknowledge message sent' in a new web page instead of being contained in the map info box the same size as the form.
When using v1.11 I keep getting this error in Chrome console:
'Uncaught TypeError: undefined is not a function'
on
'mappedcontactformpro.js:199'
I've set up a test page here:
Any idea how to fix this to make it work?
Ok I found the solution.
I suspected it was a jquery backward compatibility issue and it was.
I added these 2 lines directly after the jquery script in the header:
<script src="http://code.jquery.com/jquery-1.9.0.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script>
I found the answer here:
jquery migration page
If anyone else has this issue with the mapped contact form I hope it solves it for them too
I'm trying to display an alert on chrome using jQuery 1.3.2 as follows:
$(window).scroll(alert("Hello"));
It worked a few times, but then I received an error after five scrolls saying: TypeError: Object 100 has no method 'apply'
So I changed it to the following: $(window).scroll(function(){alert("Hello")});
But this does nothing at all whatsoever. I am testing this on Chrome. Could anyone let me know what I'm doing wrong?
The second code snippet you posted is the correct syntax for assigning a function to run on an event. That code works properly when I test it with a current version of jQuery. jQuery 1.3.2 is five years out of date, so I'd hazard a guess the issue is with the crazily old jQuery version you're trying to use.
My website was working fine until the other day. I don't know what's happened but the dropdown system for everything has stopped working completely - even the Admin bar.
When I open up the JavaScript Console in Google Chrome when I'm on the site homepage, I get this message for each dropdown item:
Uncaught TypeError: Object #<Object> has no method 'on'...
I don't know how to fix this, I've looked everywhere. Would it be in the themes "Header.php" file? If so, whereabouts?
I found the problem! I wen into the plugins section of Wordpress and disabled "LikeLocker". The only problem is, now I've got to go into the plugins code and try to figure it out haha.
Thank you anyway!