Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


OpenBadges.issue() should be able to take a string or an array #167

Rudloff opened this Issue · 3 comments

3 participants


One of my projects uses badges. When the user clicks on one of his badges, he can import it to its backpack.
But, when I click on a badge, it says "You are about to submit 65 badges" (!?).
If I click "Cool, let's go!", the popup becomes blank and nothing happens.

Here is the output of the console:

Horodatage : 17/05/2012 19:27:13
Erreur : assertions.pop is not a function
Fichier Source :
Ligne : 446

Using Firebug, I also noticed this:

"NetworkError: 404 Not Found -"
"NetworkError: 400 Bad Request -"

Here is my JS code:

/*global $, OpenBadges*/
var i;
function getUrlVars() {
    "use strict";
    var vars, parts;
    vars = {};
    parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
        vars[key] = value;
    return vars;
var GET = getUrlVars();

var issueBadge = function (e) {
    "use strict";
    var type ="data-type") ||"data-type");
    OpenBadges.issue("" + type + "&user=" + GET.user);

var getBadges = function () {
    "use strict";
    $(".badge").bind("vclick", issueBadge);

$(document).bind("pageinit", getBadges);

And here is one of my assertions:

Am I doing something wrong?



OpenBadges.issue takes an array as a first param so it can accept multiple badges at once. Your code should read

    OpenBadges.issue(["" + type + "&user=" + GET.user]);

That's why you're getting 65 badges:

"".length === 65

You can fix this now by passing in an array, but I'm leaving this open because it's bad behavior for the API to not take a string when there is a single badge being issued.

@brianloveswords brianloveswords referenced this issue from a commit
@brianloveswords brianloveswords Allow strings & arrays for first param of `issue` API .
Addresses issue #167. When a string was being passed in before, it would
not immediately fail and instead see it as an array with `"string".length`
members which is dumb and wrong. Instead of making it error, I Just made
it more lenient so that the first argument can be a string or an array.

Oh yes, it works with an array, sorry about that.


I believe this is fixed.

@stenington stenington closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.