Note that there are some explanatory texts on larger screens.

plurals
  1. POJQuery can't find variable from separate javascript file
    primarykey
    data
    text
    <p>I am using the cakephp framework and I created 2 separate javascript files and placed them into my webroot/js folder. The first javascript file contains modal dialog variables that contain the settings for the dialog boxes. The second javascript file contains other click event handlers that post data to an action and then open up the dialog.</p> <p>The problem I am having is that the second file calls a variable from the first file using $<em>variablename</em> and I get an error saying varaibleName is not defined.</p> <p>Some code is below to show you what I mean. From the first file:</p> <pre><code>var $editSel = $("#editSel_dialog").dialog( { autoOpen: false, height: 530, width: 800, resizable: true, modal: true, buttons: { "Cancel": function() { $(this).dialog("close"); } } }); </code></pre> <p>From the second file:</p> <pre><code>$('.neweditSel_dialog').live('click', function() { $.ajaxSetup({ async: false }); var selected = []; $("#[id*=LocalClocks]").each(function() { if(false != $(this).is(':checked')) { var string = $(this).attr('id').replace('LocalClocks', ''); string = string.substring(10); selected.push(string); } }); if(0 === selected.length) { $selError.dialog('open'); $selError.text('No Local Clocks Were Selected') } else { $.post('/LocalClocks/editSelected', { "data[Session][selected]": selected }, function(data) { }); $editSel.load($(this).attr('href'), function () { $editSel.dialog('open'); }); } return false; }); </code></pre> <p>This was working when I was using jquery-1.4.2.min.js, but I am using jquery1.7 now. I also ended up putting the first file with all the variables inside of <code>$(document).ready(function(){});</code> I tried putting the second file inside of a document.ready() function but that made no difference.</p> <p>Any help would be great. Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload