meteoric/meteor-ionic

#ionModal component converting "numeric String" to Number

Opened this issue · 0 comments

Summary

When using ionModal, meteor-iconic appears to converting the document _id to a Number if it comprises only numeric digits.

Example

Given the following URL http://host/test/1 for document { _id: "1" [, ...] }

A page template of:

<template name="myPage">
    <button data-ion-modal="myModal" data-id="{{this._id}}">Show</button>
</template>

An ionModal template of:

<template name="myModal">
    {{#ionModal}}
        {{doc._id}}
    {{/ionModal}}
</template>

The template.instance().data.id property in the ionModal template helper is of type Number instead of String:

Template.myModal.helpers({
    event: function () {
        var template = Template.instance();

        // The following shows the id property to be of type Number instead of String
        console.log( template.data.id );

        // Which means that something like this does not work
        return myCollection.findOne({_id: template.data.id});
        // The above does work if the document _id contains at least 1 alpha character

        // Which means that you need to do this instead
        return myCollection.findOne({_id: template.data.id.toString()});
    }
});