Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Use jQuery Plugins With Conflicting Names on the Same Page in ASP.NET

DZone's Guide to

Use jQuery Plugins With Conflicting Names on the Same Page in ASP.NET

Read on to see how this developer handled a naming conflict between a jQuery plugin and an ASP.NET web application.

· Web Dev Zone
Free Resource

Get the senior executive’s handbook of important trends, tips, and strategies to compete and win in the digital economy.

Recently, I have installed a new jQuery plugin (jQuery Masked Input Plugin by Josh Bush) to my application. I'd noticed that my existing masking functionality, that I'd already had in place, was broken somehow. Later, I found that there was a name conflict between my existing plugin and the new jQuery Masked Input Plugin that I had installed. Both plugins had the same name function "mask." In this article, we will see how we can solve it.

Problem: Error Due to jQuery Plugins With Conflicting Names

custom-extensions.js: has a mask function.

jquery.maskedinput.js: also has a mask function.

_Layout.cshtml

contactus.js: which was using existing custom-extensions.js's mask function to mask date, stopped working after adding the new jquery.maskedinput.js plugin due to a name conflict.

Solution:

_Layout.cshtml: all it needs is to rename the local copy of the mask function of jquery.maskedinput.js as shown below:

contactus.js: now I can use mask functions of both the plugins without any conflict as shown below:

That's it.

Read this guide to learn everything you need to know about RPA, and how it can help you manage and automate your processes.

Topics:
web dev ,jquery ,asp.net web development

Published at DZone with permission of Kapil Khandelwal, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}