locked
Raw Javascript V/S The jQuery ? RRS feed

  • Question

  •  So as the title suggests , we can use the web-dev skills in windows apps right? so why not use "Other Components" as well?
    We can all know Jquery is eaiser and cleaner than raw javascript , so i was trying to modify jquery current library ,(jquery being a open source) to work with windows dev enviorment , but i am struck with some errors , i assume due to the SDK , anyone know how to make it work?
    Thursday, April 18, 2013 4:05 PM

Answers

  • I don't really understand where the error HTML1701: Unable to add dynamic content '<input type='hidden' i=''/>'.  comes from. Maybe it's something different in your code?

    I've just created a blank app and added the jquery reference like this:

        <script src="/js/jquery-2.0.0-beta3.js"></script>

    to default.html.

    In default.js I wrote

        app.onactivated = function (args) {
            if (args.detail.kind === activation.ActivationKind.launch) {
                if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {
                    // TODO: This application has been newly launched. Initialize
                    // your application here.
                } else {
                    // TODO: This application has been reactivated from suspension.
                    // Restore application state here.
                }
                $("p").hide();
                args.setPromise(WinJS.UI.processAll());
            }
        };

    And I don't have any issues. 


    • Marked as answer by abhishek_94 Friday, April 19, 2013 1:52 PM
    Thursday, April 18, 2013 10:20 PM

All replies

  • jquery 2.0 will support windows store apps

    http://blogs.msdn.com/b/windowsappdev/archive/2013/04/01/windows-store-app-support-in-jquery-version-2-0.aspx

    it's currently in beta. You can download beta 3  here


    Thursday, April 18, 2013 4:37 PM
  • okay , but i got this in the error that add dynamic content directly is not allowed in vs10 , i need to use static html filter , does this mean jquery 2.0 will lack this feature?

    i am getting error with 2.0 too,

    i used just the hide() method

    $('p').hide();

    log:-

    Clear
                            
     
                             
    1 Error
                            
     
                            
    0 Warnings
                            
     
                            
    2 Messages
                            
                        
    JavaScript Console is attached and accepting commands.
    HTML1300: Navigation occurred.
    File: default.html
    HTML1701: Unable to add dynamic content '<input type='hidden' i=''/>'. A script attempted to inject dynamic content, or elements previously modified dynamically, that might be unsafe. For example, using the innerHTML property to add script or malformed HTML will generate this exception. Use the toStaticHTML method to filter dynamic content, or explicitly create elements and attributes with a method such as createElement.  For more information, see http://go.microsoft.com/fwlink/?LinkID=247104.

    • Edited by abhishek_94 Thursday, April 18, 2013 4:46 PM
    Thursday, April 18, 2013 4:41 PM
  • You'll have to change the way you're using to insert dynamic content.

    so instead of

    $("#form").append("<input name='foo' value='bar' />");

    you would let jQuery create the input element and add it to the form afterwards, like this:

    $("<input>", { name: "foo", value: "bar" }).appendTo("#form");
    For mor information on that topic, you should read this Nettuts+ Article from where I borrowed the above code example
    Thursday, April 18, 2013 4:57 PM
  • I don't really understand where the error HTML1701: Unable to add dynamic content '<input type='hidden' i=''/>'.  comes from. Maybe it's something different in your code?

    I've just created a blank app and added the jquery reference like this:

        <script src="/js/jquery-2.0.0-beta3.js"></script>

    to default.html.

    In default.js I wrote

        app.onactivated = function (args) {
            if (args.detail.kind === activation.ActivationKind.launch) {
                if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {
                    // TODO: This application has been newly launched. Initialize
                    // your application here.
                } else {
                    // TODO: This application has been reactivated from suspension.
                    // Restore application state here.
                }
                $("p").hide();
                args.setPromise(WinJS.UI.processAll());
            }
        };

    And I don't have any issues. 


    • Marked as answer by abhishek_94 Friday, April 19, 2013 1:52 PM
    Thursday, April 18, 2013 10:20 PM
  • Thanks Andre , that issue was due to beta 1 of jquery 2.0 , they fixed it in beta3 , also is it possible to use same Ajax techniques as we use in browsers?
    does windows read Xml files like browsers?
    Friday, April 19, 2013 1:52 PM