zepto $.type() function - jquery-plugins

I'm currently trying to make the jquery tokeninput plugin zepto compatible.
according to the zepto documentation in version 1.0 there should be a function called $.type() (i'm using the latest 1.0rc)
but whenever i try to call this function i recieve the following error:
Object function (a,b){return w.init(a,b)} has no method 'type'
has someone has a quick answer/fix for that?
thx

in my case typeof() did the job for my needs.
since zepto is finally out in version 1.0 it has $.type support as well.

Related

Understanding JSFs options.params in jsf.ajax.request

We migrated our JSF 2.2 based application to JSF 2.3, Except of some smaller issues we were able to get everything up and running. For one view we use Butterfaces JSF component, especially the tree component. With JSF 2.3 it was not possible to select a node and to show details of that node in another container. The apprropriate Ajax request sends the id of the node as options.params. That worked fine with JSF 2.2 but is not working anymore with JSF 2.3. We are still on Butterfaces 2 ( which should work due to downward compatibility), but even in the showcase of Butterfaces 3 on Java EE 8, the select via Ajax seems not to work.
I had a look on the jsf.ajax.request Javascript method of JSF 2.3, debugged it and realized, that the param was ignored and deleted since it seems to be the wrong format. Thus, I monkey patched the method in our application with this little stupid code snippet, to get the param sent to the server via the ajax request:
var originalJsfAjaxRequest = jsf.ajax.request;
jsf.ajax.request = function (source, event, options) {
options.params = {params: options.params};
originalJsfAjaxRequest.apply(this, [source, event, options]);
}
That's it, it is working fine again.
So my question is, where the problem is supposed to be. Is it a problem in JSF to ignore these sort of params. Or is it a problem of Butterfaces using the parameters in a wrong way? What is the correct way, to use options.params?
Thanks in advance
I don't know why, but JSF 2.3 ignores param attribute when using jsf.ajax.request. There is an ButterFaces issue: https://github.com/ButterFaces/ButterFaces/issues/232 and a new release will be released this or next week.

uirouter/angular-hybrid AoT build bootstrapModuleFactory promise injector fails to get UIRouter

I've got a sample uirouter/angular-hybrid app, successfully built with #ngtools/webpack AngularCompiler plugin and running. I've updated the main.aot.ts boot function to use bootstrapModuleFactory and can get the injector from the platformRef available in the promise success handler. But injector.get(UIRouter) fails with "Cannot read property 'config' of null."
platformBrowser().bootstrapModuleFactory(AppModuleNgFactory).then((platformRef) => {
const urlService: UrlService = platformRef.injector.get(UIRouter).urlService;
function startUIRouter() {
urlService.listen();
urlService.sync();
}
platformRef.injector.get<NgZone>(NgZone).run(startUIRouter);
});
I confirmed that the injector.get(NgZone) will succeed and injector.get(UIRouter) will fail. I tried moving the call to injector.get(UIRouter) inside the NgZone run func without success.
I also tried moving the upgrade.bootstrap call into the promise success function above to ensure it had booted first, without fixing the problem.
A simple angularjs component is rendering fine, so the boot process seems to be succeeding, except for not being able to call the listen() and sync() functions on the UIRouter.urlService.
I also confirmed the development config and non-aot production config, for this same sample app, do not have this problem and seem to be working fine.
Using versions:
uirouter/angular-hybrid v6.0.2
angular packages at v7.1.4, but also failed with 6.0.0 (which is the angular version in the package.json in the docs for uirouter/angular-hybrid v6.0.2)
Thanks for any ideas.
The problem was that the config object I was passing to UIRouterUpgradeModule.forRoot was being imported from a file that was using a default export of the object, and the object had a reference to a config function that was not being exported. This combination hid the problem during the build, and resulted in the symptom at runtime of not having the UIRouter object available to the injector.
Replacing the default export with a named export triggered the AOT compiler to complain about the non-exported function reference. Additionally exporting the function then allowed a successful build, a happy injector, and a successful runtime boot.

Jasmine Ajax request.respondWith is not working

I am using Jasmine 2.0.4 with jasmine-ajax 2.99.0 to try to test a module that calls a web service.
The code is the following:
define(['models/data-service', 'models/admin', 'models/contest', 'models/participant', 'ContestResponse'],
function(dataService, admin, Contest, Participant, ContestResponse){
"use strict";
describe("Data Service Tests", function(){
var onSuccess, onFailure, request;
describe("on new contests loaded", function(){
beforeEach(function(){
jasmine.Ajax.install();
});
it("calls onSuccess with an array of Contests", function(){
onSuccess = jasmine.createSpy('onSuccess');
onFailure = jasmine.createSpy('onFailure');
dataService.getContests()
.done(onSuccess)
.fail(onFailure);
request = jasmine.Ajax.requests.mostRecent();
expect(request.url).toBe('/api/contest');
expect(request.method).toBe('GET');
request.respondWith(ContestResponse.getResponse().contest.success);
expect(onSuccess).toHaveBeenCalled();
var successArgs = onSuccess.calls.mostRecent().args[0];
expect(successArgs.length).toEqual(4);
});
});
});
});
Everything works until it reaches the line where I try to call the respondWith method of the request. Even though I can see that the object returned from the jasmine.Ajax.requests.mostRecent() is of type FakeXMLHttpRequest, respondWidth is marked as undefined. Any Ideas?
Thanks
[UPDATE]
I have been able to narrow it down. It looks like the mock-ajax.js file is not being loaded. I have the karma-jasmine-ajax node module installed and have added jasmine-ajax to the frameworks array of the karma.conf.js like this:
frameworks: ['jasmine-ajax','jasmine', 'requirejs'],
is there anything else I need to do?
[RANT] no wonder why so few developers are running unit test with javascript [/RANT]
I faced the same issue, it looks like the latest version doesn't have respondWith method.
Downgrading the jasmine-ajax plugin made the trick:
npm install karma-jasmine-ajax#0.1.1
Now I can see respondWith is working fine.
This appears to have been a transitional problem in one of the jasmine-ajax libraries. Upgrading to latest version (3.1.0 at the time of this writing) will fix your problem.
npm install jasmine-ajax
bower install jasmine-ajax
or
jasmine-ajax on github
If you can't change jasmine-ajax versions due to conflicts (ie: you use Jasmine 1.3 or something else that has a dependency on a different version of jasmine-ajax), you can use: request.response instead of request.respondWith

Prototype error in Magento

I'm using the HelloResponsive EE theme on a Magento 1.13 EE deployment.
In setting up an extention for the eWAY gateway, I was told there was an error in the Prototype.js file that was interfering with the JSON post.
Uncaught TypeError: Object.keys called on non-object prototype.js:126 addMethods prototype.js:126 create prototype.js:115 (anonymous function) wishlist.js:38
for (var i = 0, length = properties.length; i < length; i++) klass.addMethods(properties[i]);
The custom theme does use JQuery as well, so this may be a conflict issue. But when I try moving the JQuery call before the Prototype call, the JQuery functions stop working.
Can anyone help explain 1. whether or not the error is related to the Prototype / JQuery conflict (I am using a noConflict script) and 2. how best to fix this?
Thanks!
Randy
Take a look at the answer in this thread and see if it can help you. Essentially, I had an outdated template file in my theme that was missing some key variable definitions:
https://magento.stackexchange.com/questions/7682/error-in-prototype-js

Chrome extension API: chrome.experimental.clear.* not working?

I made a simple extension that contains a button, that when clicked, executes the following code:
chrome.experimental.clear.cache('everything', function() {
});
but the callback function never seems to get called. Am I using this API wrong or is it just broken?
Here's a link to the API doc for it:
http://code.google.com/chrome/extensions/experimental.clear.html#method-cache
Thanks!
The API has changed to chrome.experimental.browsingData.
I've just landed the documentation updates to go along with the code change: http://code.google.com/chrome/extensions/trunk/experimental.browsingData.html
Here's the most up to date documentation (chrome.browsingData.removeCache):
http://developer.chrome.com/trunk/extensions/browsingData.html#method-removeCache

Resources