May 12, 2021
0
Level 4
Uncaught (in promise) TypeError is not a function
I am trying get user id on click using promise but its give me an error is not a function following is my code
$( '.descendant, .ancestor' ).hover (
function() {
prevStackIndex = $( this ).css( 'z-index' );
// update stack / zindex
$( this ).css( 'z-index', higherStackIndex );
// add wrapper
let relationWrapper = $( schemaWrapper );
$( this ).append( relationWrapper );
// get the dimesions of wrapper
let relationWrapperDimesions = {};
relationWrapperDimesions.width = relationWrapper.width();
relationWrapperDimesions.height = relationWrapper.height();
// circular position calculator
let radius = relationWrapperDimesions.width / 2.5;
let cenX = ( relationWrapperDimesions.width / 2.5 ) - 15;
let cenY = ( relationWrapperDimesions.height / 2 ) - 43;
let angle = 0;
let steps = Math.PI * 2 / relations.length;
let left, top;
// add relations
_.forEach( relations, ( relation, relationIndex ) => {
angle = relationIndex * steps;
left = cenX + Math.cos(angle) * radius;
top = cenY + Math.sin(angle) * radius;
let relationCurrent = $( schemaRelation );
let htmlImg = `<img src="/relations/${relation}-icon.png">`;
relationCurrent.html( htmlImg );
// on click event
relationCurrent.on( 'click', event => {
// let desc id
let descId = $( this ).attr( 'data-id' );
//console.table(descId)
window.activenode = descId;
//promise to send active id to
// store familyTree/userInfo
let emitPromise = new Promise( (resolve, reject) => {
console.log(path.sendData())
//this.sendData(window.activenode);
setTimeout(() => resolve("done!"), 0);
})
emitPromise.then( result => {
//$nuxt.$emit('open-dialog-form')
alert( `Adding ${relation} for user id : ${descId}` );
})
});
relationWrapper.append( relationCurrent );
relationCurrent.animate({
top: top,
left:left,
opacity: 1,
}, (75 * relationIndex) );
});
},
function() {
// update stack / zindex
$( this ).css( 'z-index', prevStackIndex );
// remove
$( this ).find( "div.wrapper-relation-circle" ).remove();
}
);
And calling following function
async sendData(value) {
await this.$store.dispatch("familyTree/userInfo", value);
},
Please or to participate in this conversation.