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

Equivalent for MvcHtmlString in ASP.NET 5?
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

Categories

HOME
fluentd
stock
cvs
jsrender
cakephp-2.5
ckeditor
alpha
serverspec
mouse
cloudkit
imacros
ab-testing
introduction
custom-wordpress-pages
conemu
amazonsellercentral
kryo
mps
trading
fopen
social-media
neo4j-spatial
gitignore
junit5
google-cloud-endpoints-v2
code-contracts
repo
form-data
revolution-slider
plsql-psp
bitbucket-pipelines
angularjs-factory
tasker
squib
graphenedb
sql-server-agent
gpx
eclipse-gef
long-polling
react-scripts
nativeapplication
pg-dump
bind9
orthogonal
background-service
eventkit
messenger
parallel-data-warehouse
azure-sdk
azure-virtual-network
asp.net5
natvis
spim
jms2
t4mvc
quicklisp
map-projections
ibaction
fluid-dynamics
system.reflection
sorl-thumbnail
xc16
dd
coldbox
titanium-modules
terminfo
sgen
srs
eclipse-memory-analyzer
back-stack
django-nonrel
robotics-studio
selected
cufon
gnu-prolog
horizontal-accordion
javax.script
table-footer
android-sdk-2.1
cxxtest
dmx512
routedevent
fixed-width
web-architecture
zend-tool
microsoft-virtualization

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App