html-helper


Configure the Javascript function + Html Helper


Is there a way to configure a Javascript(which accepts few parameters) and initialize a function with user specified parameters in an unobtrusive way with data-attributes?
Any reference would be great help
InitializeLogging({
Url: "/xxx/yyyy",
x: 10,
y: true,
somevalue: false,
unHandledErrorCallback: function (message) {
console.log("Somerror message " + message);
}
});
We can achieve that in the following way,
HTML
Call a <br />
Call b
Script
var app = {
init: function(){
this.addEventListener();
},
a: function(){ alert("You have called 'a'"); },
b: function(){ alert("You have called 'b'"); },
callMethod: function(event){
var func = $(this).attr('data-attributes');
app[func].call();
},
addEventListener: function(){
$('a').on('click', this.callMethod);
}
};
$(document).ready(function(){
app.init();
});
Demo JS http://jsfiddle.net/DfHXs/2/
Hope this will help you.

Related Links

How can i resize image in html-helper tagbuilder
TextBoxFor title to display the current text
Converting C# Razor view syntax for checkboxlist into VB.Net
Table of content is not proper in chm file
Web helpers for MVC 5?
asp.net mvc3 or mvc4 html helper is not working
Configure the Javascript function + Html Helper
Displaying multiple values with Telerik ASP.Net MVC extensions with the ForeignKey column
Custom html helpers in MVC 4
Return multiple checkbox from Custom html helper in mvc 3r
Getting Class Property Values from Linq Expression In Html Helper MVC3
format htmlhelper date field to dd/mm/yyyyy
How to create internal Linking inside CHM help file
simple_html_dom timer?
Printing Html with razor view engine
How to set the default page for a .CHM file in HTML Help Workshop?

Categories

HOME
openlayers
coq
gremlin
ngrx
programming-languages
leon
blueprintjs
upload
webrequest
iggrid
kibana-4
ibm-odm
iron-router
dynamics-crm-online
dosgi
php-openssl
facet
vision
google-cloud-nl
tinymce-4
google-rich-snippets
karaf
google-qpx-express-api
atl
force-layout
fusionpbx
android-browser
elmah
unixodbc
import-from-excel
wptoolkit
logfiles
react-scripts
pubmed
jlink
dotnetzip
lowpass-filter
carrot
worker-thread
directory-structure
titanium-android
vtigercrm
rotativa
paypal-express
gstreamer-0.10
flash-cs5
simplewebrtc
fadeout
oauth2client
teamcity-8.0
tableau-online
splash
sankey-diagram
remobjects
nstableviewcell
google-style-guide
winddk
asp.net-dynamic-data
java.util.concurrent
fpml
nsbutton
php-5.4
starcluster
concurrent-collections
srs
pyhdf
dataservice
tinn-r
nsmanagedobject
gwt-ext
php-parser
visitor-statistic
dmx512
photoshop-cs4
phonon
premature-optimization
post-build

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App