开发者

bind causing errors

I'm noticing some errors that are occurring because of JQuery bind. What ha开发者_如何学Cppens is that when I submit a form, bind causes a javascript error to occur when the page that uses it is not loaded. When I comment the bind section out, the error goes away.

Here are the relevant lines of code.

  $('input').bind('click', function() {
    editor.post();
  });

  $("#submit").click(function () {
  ...

Is there a way to move the bind click function inside of the submit click function? If not, how can I stop this error from occurring?


This is the error:

editor is not defined
script.js
editor.post();


" bind causes a javascript error to occur when the page that uses it is not loaded."

If this is the case then move your code inside document.ready(), then no code will execute untill the document is loaded.

however if u need immediate click handler action with all input element then either use more specific selector to bind so that u can check existence of the code before runnning or use try-catch :-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜