Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dont work in YM module #29

Open
ijakparov opened this issue Apr 11, 2017 · 0 comments
Open

Dont work in YM module #29

ijakparov opened this issue Apr 11, 2017 · 0 comments

Comments

@ijakparov
Copy link

ijakparov commented Apr 11, 2017

If I run ajaxq in YM module (https://github.com/ymaps/modules), it runs once and then no ajax requests sends.

`
modules.define('main-tovar-tile',function(provide, prevC) {

provide({
	init: function(){
		var _this = this;
		$("body").on("click",".main-tovar-tile__later-link",function(){

			var i =$(this).find("i");
			var id = 0;
			if(i.hasClass("fa-heart")){
				i.removeClass("fa-heart").addClass("fa-heart-o");
			}
			else{
				i.removeClass("fa-heart-o").addClass("fa-heart");
				
				id = $(this).data("id");

				_this.send_to_wishes(id);
			}
		});
	},
	send_to_wishes: function(id){
		
		$.ajaxq("atb",{
			type : "post",
			dataType : "json",
			url : "/wp/wp-admin/admin-ajax.php?action=to_wishes",
			data : {id:id},
			success: function(response) {

				if(response.success == true) {
					
					$(window).trigger("add_to_wishes",{count:response.data.count});
					alert(response.data.count);
				}



			}

		});
	}
});

});
modules.require("main-tovar-tile",function(provide){
provide.init();
});

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant