I am using Namespace Script from my control in my ASP.NET MVC application by integrating special javascript and jQuery code. Without the use of namespaces, the methods of the same name can interfere with each other and cause unwanted behavior.
This is my current working code : though In the code sample above, note that I am using a "selectIds" variable which is an array of strings. Since this variable has been declared as part of my namespace, now I have got it fully qualified The path has been compelled to refer to other methods within the same namespace. Ideally, I would like to write something like this: My current code sample looks beautiful above # 1 I feel like - I am using C # and completely using them to refer to objects without the ability to refer to objects (i.e. code sample # 2) I have used Ben Cherie Which I had started using; However, each time you create or update the module in the list of all the globals within the module code, then the maintenance looks like a nightmare < P> Name space solution syntax looks cleaner and can be perfect if I need to completely remove the "personal" variable of qualification. Does anyone have a good solution to this javascript dilemma? The easiest way I can think of is to keep a reference to your control to solve your problem. Whatever method you want to use, effectively you are just aliasing the classname.
& lt; Script type = "text / javascript" & gt; Name space ('MyCompany.MyApp.ReviseDrawingNumber.AddSheetNumber', {SelectDrawingNumbersControl: {selectedIds: [], setSelectedIds: function () {// wire-up check box $ ('# DrawingSheetNumbersGrid: checkbox'.) Live ('Change' , Function (e) {var $ check = $ (this); console.log ($ check), if ($ check.is (': checked')) // // SelectedIds MyCompany.MyApp.ReviseDrawingNumber.AddSheetNumber.SelectDrawingNumbersControl To add ID, select Ids.push ($ check.val ());} and {// Selected IDs MyCompany.MyApp.ReviseDrawingNumber.AddSheetNumber Delete the ID.Choose the downloading number. Controls selected Ids = $ Grep (MyCompany.MyApp.ReviseDrawingNumber.AddSheetNumber.SelectingNumbersControl.selectedIds, Ph (Item, index) {return items! = $ Check.val ();}}}}}}}}}}); & lt; / script & gt;
& lt; Script type = "text / javascript" & gt; Name space ('MyCompany.MyApp.ReviseDrawingNumber.AddSheetNumber', {SelectDrawingNumbersControl: {selectedIds: [], setSelectedIds: function () {// wire-up check box $ ('# DrawingSheetNumbersGrid: checkbox'.) Live ('Change' , Function (e) {var $ check = $ (this); console.log ($ check); if ($ check.is (': check')) {// Selected id selected ID selected IDs.push ($ Check.val ());} Other {// IDs removed from selected selected ids = $ .grep (Selected ids, functions (items, index) {return items! = $ Check.val ();})} }}}}}}}; & Lt; / scripts & gt;
Comments
Post a Comment