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

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -