I've surrounded my script with the following
(function ($)
{
$(document).ready(function () {....})
function HandleOpJqUIClientSide(){....}
.............
})(jQuery);
as well as embedding the following in the asp page
<script src="~/Scripts/StatsScript.js" type="text/javascript">jQuery.noConflict();</script>
I've a function in my script which is being called in server side as following
ScriptManager.RegisterStartupScript(this, typeof(Page), UniqueID, "HandleOpJqUIClientSide()", true);
it was working properly before handling my script with noconflict (as i need it due to some external plugins that conflicts with my code)
it's now throw
undefined exception
how can i manipulate the function calling from the server side again
you have to have it like this
jQuery.noConflict();
(function ($)
{
$(document).ready(function () {....})
function HandleOpJqUIClientSide(){....}
.............
})(jQuery);
remove noConflict
from script tag
Update
Actually HandleOpJqUIClientSide
is private within that scope and cannot be accessed directly from outside, we need to have a public accessor for that.
jQuery.noConflict();
var noConflict = (function ($){
$(document).ready(function () {....})
return {
HandleOpJqUIClientSide : function (){....}
}
.............
})(jQuery);
in server side
ScriptManager.RegisterStartupScript(this, typeof(Page), UniqueID, "noConflict.HandleOpJqUIClientSide()", true);
you just need to do in this way:
<script src = "other_lib.js"> </script>
<script src="jquery.js"></script >
<script type="text/javascript">
$.noConflict();
jQuery(document).ready(function ($) {
function HandleOpJqUIClientSide() {
//your $ in the code here will represent JQuery
}
});
// Code that uses other library's $ can follow here.
</script>
Outside Document ready:
var $1=JQuery();
function HandleOpJqUIClientSide() {
//your $1 in the code here will represent JQuery
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.