jquery - calling inline onclick method of javascript to anonymous not working -
i have below code in html file
<a onclick="getrestauranttiming({{ $afternoontiming[$j]->id}});">hi</a>
i have anonymous function in restaurant.js file
var restaurant = (function ($) { function getrestauranttiming(id) { alert('hi'); } })(jquery)
i want call anonymous function in onclick method.
<a onclick="restaurant.getrestauranttiming({{$afternoontiming[$j]->id}});">hi</a>
please help.
you should return this cause not instantiate object new. function inside getrestauranttiming should binded this.
var restaurant = (function($) { function getrestauranttiming(id) { alert('hi'); } this.getrestauranttiming = getrestauranttiming; return this; })(jquery); restaurant.getrestauranttiming(1);
Comments
Post a Comment