Answered by:
unbind function

Question
-
User564383478 posted
Dear all,
In the below section each scalechange calling the function showLoading. No issue with this. The problem is after the scale change hideLoading(); is not triggering. ie.Unbind is nit firing. Once the scale change over need to call hideLoading();.How to do this? Anyone help me plsviewer.bind("scaleChange", function (event)
{
showLoading();
});
viewer.unbind("scaleChange", function (event) {
hideLoading();
});function showLoading() {
loading.style.display = 'block';
}
function hideLoading() {
loading.style.display = 'none';
}Monday, September 5, 2016 4:51 PM
Answers
-
User2009744128 posted
Hi Jula,
On the basis of Bruce's advice, you can try this:
viewer.bind("scaleChange", function (event) { showLoading(); }); viewer.unbind("scaleChange", function (event) { loading.style.display = 'none'; }); function showLoading() { loading.style.display = 'block'; }
hope this helps.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, September 6, 2016 12:31 PM
All replies
-
User-474980206 posted
the unbind() method removes an event handler. if you pass no method all are unbound, if you pass one, then only that one is unbound. in you case because you pass an anonymous function to the unbind(), nothing happens because that function wasn't already bound, and will not be found.
Monday, September 5, 2016 9:27 PM -
User564383478 posted
TY
Can u tell me how the below code i can do in the sugested way?
viewer.bind("scaleChange", function (event)
{
showLoading();
});
viewer.unbind("scaleChange", function (event){
hideLoading();
});function showLoading() {
loading.style.display = 'block';
}
function hideLoading() {
loading.style.display = 'none';
}Tuesday, September 6, 2016 4:10 AM -
User-1142886626 posted
Hi jula,
The problem is after the scale change hideLoading(); is not triggering. ie.Unbind is nit firing.You could refer to the following example.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> <script type="text/javascript"> $(function () { $("p").click(function () { showLoading(); }) $("#Button1").click(function () { $("p").bind("click", function () { showLoading(); }) }) $("#Button2").click(function () { $("p").unbind(); }) }) function showLoading() { alert("bindevent"); } </script> <body> <p>This is a paragraph.</p> <p>This is another paragraph.</p> <p>Click any p element.</p> <input id="Button1" type="button" value="addEvent" /> <input id="Button2" type="button" value="removeEvent" /> </body>
Hope this can help you. If you have any question and confusion about the problem. Please don't hesitate to let me know.
Best Regards,
Ailleen
Tuesday, September 6, 2016 9:54 AM -
User2009744128 posted
Hi Jula,
On the basis of Bruce's advice, you can try this:
viewer.bind("scaleChange", function (event) { showLoading(); }); viewer.unbind("scaleChange", function (event) { loading.style.display = 'none'; }); function showLoading() { loading.style.display = 'block'; }
hope this helps.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Tuesday, September 6, 2016 12:31 PM